Batman.js is no longer in production at Shopify and is not actively maintained.

This website is left for reference (and for old times' sake).

batman.js

Batman.SetIntersection extends Batman.BinarySetOperation. It implements an intersection operation: it contains members of both sets passed to its constructor without duplicates.

Since Batman.SetIntersection is a subclass of Batman.Set, you can use it just like a Batman.Set.

test 'SetIntersection contains the intersection of two sets', ->
  left = new Batman.Set(1, 2, 3)
  right = new Batman.Set(3, 4, 5)
  operation = new Batman.SetIntersection(left, right)
  ok !operation.has(1), 'doesnt have items from the left set only'
  ok !operation.has(4), 'doesnt have items from the right set only'
  ok operation.has(3), 'has items from both sets'

Help us improve our documentation!

Contributions to this page are welcome on Github. If you find a problem but you cannot fix it, please open an issue.

Discussion regarding batman.js documentation is also welcome on our mailing list.