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.SetUnion extends Batman.BinarySetOperation. It implements a union operation: the SetUnion contains members found in either set passed to the constructor, without duplicates.

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

test 'SetUnion contains the union of two sets', ->
  left = new Batman.Set(1, 2, 3)
  right = new Batman.Set(3, 4, 5)
  operation = new Batman.SetUnion(left, right)
  ok operation.has(1), 'has items from the left set'
  ok operation.has(4), 'has items from the right set'
  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.