# set-functions

> Common functions for set operations

Latest version **0.3.0** (published 2016-12-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install set-functions
pnpm add set-functions
yarn add set-functions
bun add set-functions
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2016-12-03 |
| First published | 2015-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Maintainers | robbie-c |

## Links

- npm: https://www.npmjs.com/package/set-functions
- Repository: https://github.com/robbie-c/js-set-functions
- Homepage: https://github.com/robbie-c/js-set-functions#readme
- Issues: https://github.com/robbie-c/js-set-functions/issues
- npm.io page: https://npm.io/package/set-functions

## Recent versions

- 0.3.0 (latest) — 2016-12-03
- 0.2.0 — 2016-03-25
- 0.1.0 — 2015-10-21
- 0.0.2 — 2015-10-21
- 0.0.1 — 2015-10-21

## README

# Set Functions
The [ES6 Set Class]
(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
does not provide functions to union or intersect Sets, so I created this library
so that it was no longer necessary to keep rewriting these functions for every
project.

These functions do not modify their arguments, and when a Set is returned it
will be a new one.

# Usage Example

```JavaScript
var SetFunctions = require('set-functions');

var set1 = new Set([1,2,3]);
var set2 = new Set([2,3,4]);

SetFunctions.intersection(set1, set2); // Set [ 2, 3 ]

SetFunctions.union(set1, set2); // Set [ 1, 2, 3, 4 ]
SetFunctions.add(set1, set2); // alias for union

SetFunctions.difference(set1, set2); // Set [ 1 ]
SetFunctions.subtract(set1, set2); // alias for difference

SetFunctions.symmetricDifference(set1, set2); // Set [1, 4]
SetFunctions.disjunction(set1, set2); // alias for symmetricDifference

SetFunctions.isEqual(set1, set2); // false
SetFunctions.isEqual(set1, new Set([1, 2, 3])); // true
(new Set([1,2,3])) == (new Set([1,2,3])); // false, same with ===

// these functions can also take Arrays, and will treat them as Sets
SetFunctions.isEqual([1, 1, 2], [2, 1])); // true
```

---
_Source: https://npm.io/package/set-functions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
