Set data structure for JavaScript (MIT)
JavaScript
Latest commit 4f272a3 Aug 15, 2013 @bebraw Add set example
Permalink
Failed to load latest commit information.
dist
src Refactor and tidy up Aug 14, 2013
.gitignore Initial commit Aug 14, 2013
.travis.yml Set up travis Aug 14, 2013
Gruntfile.js Initial commit Aug 14, 2013
LICENSE Initial commit Aug 14, 2013
README.md Add set example Aug 15, 2013
package.json Bump version Aug 14, 2013
tests.js Making sure 'set' produces a truly immutable object, and fixing a cou… Aug 14, 2013

README.md

NPM version Dependency Status build status

setjs - Set data structure for JavaScript

setjs implements a a Set API inspired by Python. There are some differences, though. The biggest difference is that the API is immutable by design. There is a basic set structure and functions that operate upon it. Consider the API below:

var a = set(4, 3, 4, 3); // set accepts arbitrary amount of items and may be empty
var b = set(4, 5);
var c = set(b, 6); // set accepts sets too. this results in {4, 5, 6}

set.count(a); // 2
set.contains(a, 3); // true
set.equals(a, a); // true
set.equals(a, set()); // false

set.union(a, b); // {3, 4, 5}
set.intersection(a, b); // {4}
set.difference(a, b); // {5}
set.symmetricDifference(a, b); // {3, 5}

Contributors

License

MIT.