{"id":17484685,"url":"https://github.com/ryanmcdermott/set-tools","last_synced_at":"2025-07-04T15:36:50.477Z","repository":{"id":57356970,"uuid":"55010058","full_name":"ryanmcdermott/set-tools","owner":"ryanmcdermott","description":"Function extensions to supercharge JavaScript's Set type with common set operations","archived":false,"fork":false,"pushed_at":"2016-04-22T16:30:41.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T10:19:47.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanmcdermott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-29T20:58:16.000Z","updated_at":"2019-01-31T04:34:35.000Z","dependencies_parsed_at":"2022-09-26T16:31:59.488Z","dependency_job_id":null,"html_url":"https://github.com/ryanmcdermott/set-tools","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ryanmcdermott/set-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmcdermott%2Fset-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmcdermott%2Fset-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmcdermott%2Fset-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmcdermott%2Fset-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanmcdermott","download_url":"https://codeload.github.com/ryanmcdermott/set-tools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanmcdermott%2Fset-tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262925063,"owners_count":23385470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-19T01:05:17.490Z","updated_at":"2025-07-04T15:36:50.425Z","avatar_url":"https://github.com/ryanmcdermott.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# set-tools [![Build Status](https://api.travis-ci.org/ryanmcdermott/set-tools.svg?branch=master)](https://travis-ci.org/ryanmcdermott/set-tools)\n\n\n## What is it?\n`set-tools` is a prototype extension module for beefing up JavaScript's `Set` type to include all of your favorite set operations, including `difference`, `union`, `intersection`, `issubset`, `issuperset`, and `toArray`.\n\n\n## What else?\nThis module is a bit naughty. Normally you are not supposed to extend global JavaScript prototypes. **This is because it affects any and all other modules you have loaded.**  Having said that, these operations are useful and will hopefully be introduced one day as native methods on `Set`. Assuming no other module is requiring `Set` to have different implementations of these methods or for some reason requiring them *not* to be there, then this module won't harm anything.\n\n## Installation\n`npm install set-tools --save`\n\n\n## Usage\n```js\nrequire('set-tools'); // requiring it supercharges Set prototype automatically.\n\nvar s, cmp, results;\n\n/**\n * intersection\n */\ns = new Set([1, 3, 5, 7, 9]);\ncmp = new Set([2, 3, 8, 9]);\nresults = s.intersection(cmp); // Set {3, 9}\n\n\n\n\n/**\n * union\n */\ns = new Set([1, 3, 5, 7, 9]);\ncmp = new Set([2, 3, 8, 9]);\nresults = s.union(cmp); // Set {2, 3, 8, 9, 1, 5, 7}\n\n\n\n\n/**\n * difference\n */\ns = new Set([1, 3, 5, 7, 9]);\ncmp = new Set([2, 3, 8, 9]);\nresults = s.difference(cmp); // Set {1, 5, 7}\n\n\n\n\n/**\n * issuperset\n */\ns = new Set([1, 3, 5, 7, 9]);\ncmp = new Set([3, 5]);\nresults = s.issuperset(cmp); // true\n\ns = new Set([1, 3, 5, 7, 9]);\ncmp = new Set([3, 8]);\nresults = s.issuperset(cmp); // false\n\n\n\n\n/**\n * issubset\n */\ns = new Set([11, 15, 18, 20]);\ncmp = new Set([11, 15, 18, 20, 25, 89, 100]);\nresults = s.issubset(cmp); // true\n\ns = new Set([11, 15, 18, 57, 62]);\ncmp = new Set([11, 15, 18, 20, 25, 89, 100]);\nresults = s.issubset(cmp); // false\n```\n\n\n## Contributing\nPull requests are much appreciated and accepted.\n\n\n## License\nReleased under the [MIT License](http://www.opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanmcdermott%2Fset-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanmcdermott%2Fset-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanmcdermott%2Fset-tools/lists"}