{"id":13468521,"url":"https://github.com/terkelg/zet","last_synced_at":"2025-04-04T09:10:02.938Z","repository":{"id":46511010,"uuid":"147027504","full_name":"terkelg/zet","owner":"terkelg","description":"Set() as it should be.","archived":false,"fork":false,"pushed_at":"2020-04-29T17:02:45.000Z","size":73,"stargazers_count":519,"open_issues_count":1,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T08:09:31.284Z","etag":null,"topics":["difference","intersection","set","set-theory","sets","union"],"latest_commit_sha":null,"homepage":"","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/terkelg.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":"2018-09-01T19:42:32.000Z","updated_at":"2025-03-06T07:05:41.000Z","dependencies_parsed_at":"2022-08-12T12:51:01.170Z","dependency_job_id":null,"html_url":"https://github.com/terkelg/zet","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fzet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fzet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fzet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terkelg%2Fzet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terkelg","download_url":"https://codeload.github.com/terkelg/zet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149505,"owners_count":20891954,"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":["difference","intersection","set","set-theory","sets","union"],"created_at":"2024-07-31T15:01:12.784Z","updated_at":"2025-04-04T09:10:02.921Z","avatar_url":"https://github.com/terkelg.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","*.js"],"sub_categories":["General"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"zet.png\" alt=\"zet\" width=\"200\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/zet\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/zet\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/terkelg/zet/actions\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/github/status/terkelg/zet\" alt=\"build status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/terkelg/zet\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/codecov/c/github/terkelg/zet\" alt=\"codecov\" /\u003e\n  \u003c/a\u003e\n  \u003c!--\u003ca href=\"https://npmjs.org/package/zet\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/dm/zet\" alt=\"downloads\" /\u003e\n  \u003c/a\u003e--\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=zet\"\u003e\n    \u003cimg src=\"https://packagephobia.now.sh/badge?p=zet\" alt=\"install size\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cb\u003eJavaScript Set() as it should be.\u003c/b\u003e\u003c/p\u003e\n\nECMAScript 6 sets have no methods for computing the union (∪), intersection (∩) or difference (⊖).\nZet is an extension of ES6 [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) and comes with all its functionality included with extra set logic.\nThe API is similar to how sets work in [Python](https://docs.python.org/2/library/stdtypes.html#set).\n\n\n## Features\n\nAdditions to the default ECMAScript 6 set\n\n- Union (∪)\n- Intersection (∩)\n- Difference/subtract (-)\n- Symmetric difference (⊖)\n- Subset (⊆)\n- Superset (⊇)\n- Map\n- Filter\n- Reduce\n\n\nAdditionally, this module is delivered as:\n\n* **ES Module**: `dist/zet.mjs`\n* **CommonJS**: `dist/zet.js`\n* **UMD**: `dist/zet.umd.js`\n\n\n## Install\n\n```\n$ npm install --save zet\n```\n\n\n## Usage\n\n```js\nimport Zet from 'zet';\n\nlet a = new Zet([1, 2, 3]);\nlet b = new Zet([3, 4, 5]);\nlet c = new Zet([2, 3, 4]);\n\nZet.union(a, b);\n//=\u003e [Zet] {1, 2, 3, 4, 5}\n\na.union(b, c);\n//=\u003e [Zet] {1, 2, 3, 4, 5}\n\na.intersection(b);\n//=\u003e [Zet] {3}\n\na.symmetricDifference(c);\n//=\u003e [Zet] {1, 4}\n\na.subset(b);\n//=\u003e false\n\na.filter(i =\u003e i % 2);\n//=\u003e [Zet] {1, 3}\n\n```\n\n\n# API\n\n## Zet([iterable])\nReturns:`Zet`\n\nReturns the Zet instance.\n\n**Zet extends [`Set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) and inherit all its functionality, like `has()`, `size()` etc.**\n\n### Zet.union(...sets) ∪\nReturns:`zet`\n\nStatic variadic function that return a new set with elements from all other `sets`.\n\n#### sets\nType: `Zet|Set`\n\nTwo or more sets of type `Zet` or `Set`.\n\n### Zet.intersection(...sets) ∩\nReturns:`zet`\n\nStatic variadic function that return a new set with elements common to `this` and all other `sets`.\n\n#### sets\nType: `Zet|Set`\n\nTwo or more sets of type `Zet` or `Set`.\n\n### Zet.difference(...sets) - or \\\\\nReturns:`zet`\n\nReturns the difference between two or more sets. The order of the sets matters. Sets are differentiated against the first argument/set.\n\n#### sets\nType: `Zet|Set`\n\nTwo or more sets of type `Zet` or `Set`.\n\n### Zet.symmetricDifference(setA, setB) ⊖ or ∆\nReturns:`zet`\n\nStatic function that return a new set with elements in either setA or setB but not both.\n\n#### setA\nType: `Zet|Set`\n\nSet A of type `Zet` or `Set`.\n\n#### setB\nType: `Zet|Set`\n\nSet B of type `Zet` or `Set`.\n\n### Zet.subset(setA, setB)\nReturns: `Boolean`\n\nTest whether every element in `setB` is in `setA`.\n\n#### setA\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n#### setB\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n### Zet.superset(setA, setB)\nReturns: `Boolean`\n\nTest whether every element in `setA` is in `setB`.\n\n#### setA\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n#### setB\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n### map(set, func)\nReturns: `Zet|Set`\n\nCreates a set with the results of calling the provided function on every element.\n\n#### set\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n#### func\nType: `Function`\n\nFunction that produces an element of the new set.\n\n### filter(set, func)\nReturns: `Zet|Set`\n\nCreates a set with all elements that pass the test implemented by the provided function.\n\n#### set\nType: `Zet|Set`\nIt is the set going to be examined.\n\n#### func\nType: `Function`\n\nIt is a predicate, to test each element of the set.\n\n### reduce(set, func, *initializer*)\nReturns: `Number`\n\nReduces the set to a single value, by executing the provided function for each element in the set (from left-to-right).\n\n#### set\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n#### func\nType: `Function`\n\nFunction to be executed for each element in the set.\n\n#### *initializer*\nType: `Number`\n\nOptional. A value to be passed to the function as the initial value.\n\n## Instance Methods\n\n### union(...sets) ∪\nReturns:`zet`\n\nVariadic method that return a new set with elements from `this` and all other `sets`.\n\n#### sets\nType: `Zet|Set`\n\nOne or more sets of type `Zet` or `Set`.\n\n### intersection(...sets) ∩\nReturns:`zet`\u003cbr\u003e\n\nVariadic method that return a new set with elements common to `this` and all other `sets`.\n\n#### sets\nType: `Zet|Set`\n\nOne or more sets of type `Zet` or `Set`.\n\n### difference(...sets) - or \\\\\nReturns:`zet`\u003cbr\u003e\n\nVariadic method tht return a new set with elements in `this` that are not in the other `sets`.\n\n#### sets\nType: `Zet|Set`\n\nOne or more sets of type `Zet` or `Set`.\n\n### symmetricDifference(other) ⊖ or ∆\nReturns:`zet`\n\nMethod that return a new set with elements in either `this` or `other` but not both. This is also known as xor.\n\n#### other\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n### subset(other)\nReturns: `Boolean`\n\nTest whether every element in the set is in `other`.\n\n#### other\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n### superset(other)\nReturns: `Boolean`\n\nTest whether every element in `other` is in the set.\n\n#### other\nType: `Zet|Set`\n\nSet of type `Zet` or `Set`.\n\n### map(func)\nReturns: `Zet|Set`\n\nCreates a set with the results of calling the provided function on every element.\n\n#### func\nType: `Function`\n\nFunction that produces an element of the new set.\n\n### filter(func)\nReturns: `Zet|Set`\n\nCreates a set with all elements that pass the test implemented by the provided function.\n\n#### func\nType: `Function`\n\nIt is a predicate, to test each element of the set.\n\n### reduce(func, *initializer*)\nReturns: `Number`\n\nReduces the set to a single value, by executing the provided function for each element in the set (from left-to-right).\n\n#### func\nType: `Function`\n\nFunction to be executed for each element in the set.\n\n#### *initializer*\nType: `Number`\n\nOptional. A value to be passed to the function as the initial value.\n\n## License\n\nMIT © [Terkel Gjervig](https://terkel.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterkelg%2Fzet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterkelg%2Fzet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterkelg%2Fzet/lists"}