GenericSet

An abstract collection that implements many generic methods, reusable by most sets.

Methods

union(values)

Returns the set of values including all values from both of these sets.

intersection(values)

Returns the set of values that are in both of these sets.

difference(values)

Returns the set of values that are in this set, excluding the values that are also in the other set.

symmetricDifference(values)

Returns the set of values that are only in one of these sets.

remove(value)

An alias for delete(value) on sets that increases the overlap with the W3C DOMTokenList interface, implemented by classList.

contains(value)

An alias for has(value) on sets that increases the overlap with the W3C DOMTokenList interface, implemented by classList.

toggle(value)

Toggles the existence of a value in a set.

deleteAll(value, equals?)

Deletes every value equivalent to the given value from the collection.

toJSON()

Used by JSON.stringify to create a JSON representation of the collection.

equals(value, equals?)

Returns whether this collection is equivalent to the given collection.

Usage

require("collections/shim-object");
var GenericSet = require("collections/generic-set");
Object.addEach(MySet.prototype, GenericSet.prototype);
  • GenericSet
Source code