{"id":19050480,"url":"https://github.com/blakek/set-operations","last_synced_at":"2025-10-29T07:18:22.582Z","repository":{"id":77618668,"uuid":"315365602","full_name":"blakek/set-operations","owner":"blakek","description":"🧮 Common set operations (union, difference, isSubset, etc.) for any Iterable","archived":false,"fork":false,"pushed_at":"2020-11-23T15:59:13.000Z","size":91,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T13:08:13.857Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/blakek.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-23T15:55:33.000Z","updated_at":"2021-12-13T14:37:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"35199c63-7c40-45d5-aa28-411f88bb7535","html_url":"https://github.com/blakek/set-operations","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"7732494bf2cb3a10c1d8624451f39b7bf9f8c05a"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fset-operations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fset-operations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fset-operations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakek%2Fset-operations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakek","download_url":"https://codeload.github.com/blakek/set-operations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240107132,"owners_count":19748759,"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-11-08T23:15:03.792Z","updated_at":"2025-10-19T19:27:24.970Z","avatar_url":"https://github.com/blakek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# set-operations\n\n\u003e 🧮 Common set operations (union, difference, isSubset, etc.) for any Iterable\n\nProvides helpers like `isSuperset`, `difference`, etc. for Iterables.\n\n## Install\n\nUsing [Yarn]:\n\n```bash\n$ yarn add @blakek/set-operations\n```\n\n…or using [npm]:\n\n```bash\n$ npm i --save @blakek/set-operations\n```\n\n## API\n\n```js\nimport {\n  difference,\n  filter,\n  intersection,\n  isSubset,\n  isSuperset,\n  symmetricDifference,\n  union\n} from '@blakek/set-operations';\n\ndifference();\n```\n\n### `difference`\n\n```ts\nfunction difference\u003cT\u003e(groupA: Iterable\u003cT\u003e, groupB: Iterable\u003cT\u003e): Iterable\u003cT\u003e;\n```\n\nReturns values in one group not in another:\n\n```js\nimport { difference } from '@blakek/set-operations';\n\ndifference(['a', 'b', 'c'], ['b', 'a']);\n// » Set { 'c' }\n```\n\n### `filter`\n\n```ts\nfunction filter\u003cT\u003e(group: Set\u003cT\u003e, fn: (value: T) =\u003e boolean): Set\u003cT\u003e;\n```\n\nReturns a new Set from all elements in a group matching a filtering function:\n\n```js\nimport { filter } from '@blakek/set-operations';\n\nfilter(new Set([1, 2, 3, 4, 5]), x =\u003e x \u003c 4);\n// » Set { 1, 2, 3 }\n```\n\n### `intersection`\n\n```ts\nfunction intersection\u003cT\u003e(groupA: Iterable\u003cT\u003e, groupB: Iterable\u003cT\u003e): Iterable\u003cT\u003e;\n```\n\nReturns only values shared between groups:\n\n```js\nimport { intersection } from '@blakek/set-operations';\n\nintersection([4, 5, 6], [5, 6]);\n// » Set { 5, 6 }\n\nintersection('showers', 'flowers');\n// » Set { 's', 'o', 'w', 'e', 'r' }\n```\n\n### `isSubset`\n\n```ts\nfunction isSubset\u003cT\u003e(groupA: Iterable\u003cT\u003e, groupB: Iterable\u003cT\u003e): boolean;\n```\n\nReturns if the first group is a subset of the second:\n\n```js\nimport { isSubset } from '@blakek/set-operations';\n\nisSubset([4, 5, 6], [5, 6]);\n// » false\n\nisSubset([2, 4, 6], [1, 2, 3, 4, 5, 6]);\n// » true\n\nisSubset('fame', 'frame');\n// » true\n```\n\n### `isSuperset`\n\n```ts\nfunction isSuperset\u003cT\u003e(groupA: Iterable\u003cT\u003e, groupB: Iterable\u003cT\u003e): boolean;\n```\n\nReturns if the first group is a superset of the second:\n\n```js\nimport { isSuperset } from '@blakek/set-operations';\n\nisSuperset([4, 5, 6], [5, 6]);\n// » true\n\nisSuperset([2, 4, 6], [1, 2, 3, 4, 5, 6]);\n// » false\n\nisSuperset('fame', 'frame');\n// » false\n```\n\n### `symmetricDifference`\n\n```ts\nfunction symmetricDifference\u003cT\u003e(\n  groupA: Iterable\u003cT\u003e,\n  groupB: Iterable\u003cT\u003e\n): Iterable\u003cT\u003e;\n```\n\nReturns values in either group not in both:\n\n```js\nimport { symmetricDifference } from '@blakek/set-operations';\n\nsymmetricDifference([2, 4, 6], [1, 2, 3, 4, 5, 6]);\n// » Set { 1, 3, 5 }\n\nsymmetricDifference('shower', 'flower');\n// » Set { 's', 'h', 'f', 'l' }\n```\n\n### `union`\n\n```ts\nfunction union\u003cT\u003e(groupA: Iterable\u003cT\u003e, groupB: Iterable\u003cT\u003e): Iterable\u003cT\u003e;\n```\n\nReturns all values from each group:\n\n```js\nimport { union } from '@blakek/set-operations';\n\nunion([2, 4, 6], [1, 2, 3, 4, 5, 6]);\n// » Set { 2, 4, 6, 1, 3, 5 }\n\nunion('fun', 'sun');\n// » Set { 'f', 'u', 'n', 's' }\n```\n\n## Contributing\n\n[Node.js] and [Yarn] are required to work with this project.\n\nTo install all dependencies, run:\n\n```bash\nyarn\n```\n\nThen, you can start the test server to get started:\n\n```bash\nyarn test --watch\n```\n\nSee below for other scripts.\n\n### Useful Commands\n\n|                     |                                                 |\n| ------------------- | ----------------------------------------------- |\n| `yarn build`        | Builds the project to `./dist`                  |\n| `yarn format`       | Format the source following the Prettier styles |\n| `yarn test`         | Run project tests                               |\n| `yarn test --watch` | Run project tests, watching for file changes    |\n\n## License\n\nMIT\n\n[node.js]: https://nodejs.org/\n[yarn]: https://yarnpkg.com/en/docs/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakek%2Fset-operations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakek%2Fset-operations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakek%2Fset-operations/lists"}