setjs
Set data structure
Last updated 7 years ago by bebraw .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install setjs 
SYNC missed versions from official npm registry.

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);

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}

The functions above may be used to perform various manipulations on sets. Note that due to the underlying structure (Object) you may actually mutate a set using delete and assignment (ie. a['4'] = true;, the value can be anything). .

License

MIT.

Current Tags

  • 0.6.0                                ...           latest (7 years ago)

2 Versions

  • 0.6.0                                ...           7 years ago
  • 0.5.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |