This is a `playground`

to test code. It runs a full `Node.js`

environment and already has all of `npm`

’s 1,000,000+ packages pre-installed, including `zet`

with all `npm`

packages installed. **Try it out**:

var zet = require("zet")

- all documents on RunKit are public
`require()`

any package directly from npm- use arrow functions, classes, template strings, and most of ES6
`await`

any promise instead of using callbacks (example)- create your own embedded
**node.js**snippets

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

**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`

and comes with all its functionality included with extra set logic.
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 (⊇)
- Map
- Filter
- Reduce

Additionally, this module is delivered as:

**ES Module**:`dist/zet.mjs`

**CommonJS**:`dist/zet.js`

**UMD**:`dist/zet.umd.js`

```
$ npm install --save zet
```

```
import Zet from 'zet';
let a = new Zet([1, 2, 3]);
let b = new Zet([3, 4, 5]);
let c = new Zet([2, 3, 4]);
Zet.union(a, b);
//=> [Zet] {1, 2, 3, 4, 5}
a.union(b, c);
//=> [Zet] {1, 2, 3, 4, 5}
a.intersection(b);
//=> [Zet] {3}
a.symmetricDifference(c);
//=> [Zet] {1, 4}
a.subset(b);
//=> false
a.filter(i => i % 2);
//=> [Zet] {1, 3}
```

Returns:`Zet`

Returns the Zet instance.

**Zet extends Set() and inherit all its functionality, like has(), size() etc.**

Returns:`zet`

Static variadic function that return a new set with elements from all other `sets`

.

Type: `Zet|Set`

Two or more sets of type `Zet`

or `Set`

.

Returns:`zet`

Static variadic function that return a new set with elements common to `this`

and all other `sets`

.

Type: `Zet|Set`

Two or more sets of type `Zet`

or `Set`

.

Returns:`zet`

Returns the difference between two or more sets. The order of the sets matters. Sets are differentiated against the first argument/set.

Type: `Zet|Set`

Two or more sets of type `Zet`

or `Set`

.

Returns:`zet`

Static function that return a new set with elements in either setA or setB but not both.

Type: `Zet|Set`

Set A of type `Zet`

or `Set`

.

Type: `Zet|Set`

Set B of type `Zet`

or `Set`

.

Returns: `Boolean`

Test whether every element in `setB`

is in `setA`

.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Returns: `Boolean`

Test whether every element in `setA`

is in `setB`

.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Returns: `Zet|Set`

Creates a set with the results of calling the provided function on every element.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Type: `Function`

Function that produces an element of the new set.

Returns: `Zet|Set`

Creates a set with all elements that pass the test implemented by the provided function.

Type: `Zet|Set`

It is the set going to be examined.

Type: `Function`

It is a predicate, to test each element of the set.

Returns: `Number`

Reduces the set to a single value, by executing the provided function for each element in the set (from left-to-right).

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Type: `Function`

Function to be executed for each element in the set.

Type: `Number`

Optional. A value to be passed to the function as the initial value.

Returns:`zet`

Variadic method that return a new set with elements from `this`

and all other `sets`

.

Type: `Zet|Set`

One or more sets of type `Zet`

or `Set`

.

Returns:`zet`

Variadic method that return a new set with elements common to `this`

and all other `sets`

.

Type: `Zet|Set`

One or more sets of type `Zet`

or `Set`

.

Returns:`zet`

Variadic method tht return a new set with elements in `this`

that are not in the other `sets`

.

Type: `Zet|Set`

One or more sets of type `Zet`

or `Set`

.

Returns:`zet`

Method that return a new set with elements in either `this`

or `other`

but not both. This is also known as xor.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Returns: `Boolean`

Test whether every element in the set is in `other`

.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Returns: `Boolean`

Test whether every element in `other`

is in the set.

Type: `Zet|Set`

Set of type `Zet`

or `Set`

.

Returns: `Zet|Set`

Creates a set with the results of calling the provided function on every element.

Type: `Function`

Function that produces an element of the new set.

Returns: `Zet|Set`

Creates a set with all elements that pass the test implemented by the provided function.

Type: `Function`

It is a predicate, to test each element of the set.

Returns: `Number`

Reduces the set to a single value, by executing the provided function for each element in the set (from left-to-right).

Type: `Function`

Function to be executed for each element in the set.

Type: `Number`

Optional. A value to be passed to the function as the initial value.

MIT © Terkel Gjervig

- package on npmhttps://npmjs.com/package/zet
- licenseMIT

RunKit is a free, in-browser JavaScript dev environment for prototyping **Node.js** code, with every **npm** package installed. Sign up to share your code.

Sign Up for Free