Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manipulation with sets #47

Open
3 tasks
blond opened this issue Mar 26, 2017 · 0 comments
Open
3 tasks

Manipulation with sets #47

blond opened this issue Mar 26, 2017 · 0 comments

Comments

@blond
Copy link
Owner

blond commented Mar 26, 2017

Add static methods to created instance of HashSet:

  • merge
  • intersect
  • subtract
const hashSet = require('hash-set');

// Create Set class which compares objects with JSON.stringify
const JSONSet = hashSet(JSON.stringify);
const set1 = new JSONSet([{ a: 1 }, { b: 2 }]);
const set2 = new JSONSet([{ c: 3 }, { b: 2 }]);

JSONSet.merge(set1, set2); // [{ a: 1 }, { c: 3 }, { b: 2 }]
JSONSet.intersect(set1, set2); // [{ b: 2 }]
JSONSet.subtract(set1, set2); // [{ a: 1 }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant