Package Exports
- zet
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (zet) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
JavaScript Set() as it should be.
ECMAScript 6 sets have no methods for computing the union (∪), intersection (∩) or difference (⊖). Zet is an extension of ES6 Set with such features included. The API is similar to how sets work in Python.
Additions to the default ECMAScript 6 set
- ∪ union
- ∩ intersection
- - difference/subtract
- ⊖ symmetric difference
- ⊆ subset
- ⊇ superset
Install
$ npm install --save zetUsage
const Zet = require('zet');
let a = new Zet([1, 2, 3]);
let b = new Zet([3, 4, 5]);
Zet.union(a, b);
//=> [Zet] {1, 2, 3, 4, 5}
a.intersection(b);
//=> [Zet] {3}API
Zet([iterable])
Returns:Zet
Returns the Zet instance.
Zet extends Set() and inherit all its functionality, like has(), size() etc.
Zet.union(...sets) ∪
Returns:zet
Static variadic function that return a new set with elements from all other sets.
sets
Type: Zet|Set
Two or more sets of type Zet or Set.
Zet.intersection(...sets) ∩
Returns:zet
Static variadic function that return a new set with elements common to this and all other sets.
sets
Type: Zet|Set
Two or more sets of type Zet or Set.
Zet.difference(...sets) - or \
Returns:zet
Returns the difference between two or more sets. The order of the sets matters. Sets are differentiated against the first argument/set.
sets
Type: Zet|Set
Two or more sets of type Zet or Set.
Zet.symmetricDifference(setA, setB) ⊖ or ∆
Returns:zet
Static funciont that return a new set with elements in either setA or setB but not both.
setA
Type: Zet|Set
Set A of type Zet or Set.
setB
Type: Zet|Set
Set B of type Zet or Set.
subset(setA, setB)
Returns: Boolean
Test whether every element in setB is in setA.
setA
Type: Zet|Set
Set of type Zet or Set.
setB
Type: Zet|Set
Set of type Zet or Set.
superset(setA, setB)
Returns: Boolean
Test whether every element in setA is in setB.
setA
Type: Zet|Set
Set of type Zet or Set.
setB
Type: Zet|Set
Set of type Zet or Set.
Instance Methods
union(...sets) ∪
Returns:zet
Variadic method that return a new set with elements from this and all other sets.
sets
Type: Zet|Set
One or more sets of type Zet or Set.
intersection(...sets) ∩
Returns:zet
Variadic method that return a new set with elements common to this and all other sets.
sets
Type: Zet|Set
One or more sets of type Zet or Set.
difference(...sets) - or \
Returns:zet
Variadic method tht return a new set with elements in this that are not in the other sets.
sets
Type: Zet|Set
One or more sets of type Zet or Set.
symmetricDifference(other) ⊖ or ∆
Returns:zet
Method that return a new set with elements in either this or other but not both. This is also known as xor.
other
Type: Zet|Set
Set of type Zet or Set.
subset(other)
Returns: Boolean
Test whether every element in the set is in other.
other
Type: Zet|Set
Set of type Zet or Set.
superset(other)
Returns: Boolean
Test whether every element in other is in the set.
other
Type: Zet|Set
Set of type Zet or Set.
License
MIT © Terkel Gjervig