{"id":21691521,"url":"https://github.com/scientific-dev/node-set-theory","last_synced_at":"2026-05-19T15:36:44.015Z","repository":{"id":136131768,"uuid":"305416149","full_name":"scientific-dev/node-set-theory","owner":"scientific-dev","description":"Simple package to calculate set theory using javascript...","archived":false,"fork":false,"pushed_at":"2021-08-16T11:05:09.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T04:35:17.645Z","etag":null,"topics":["javascript","maths","sets","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/node-set-theory","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/scientific-dev.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-10-19T14:42:51.000Z","updated_at":"2021-09-05T09:29:14.000Z","dependencies_parsed_at":"2023-05-27T11:30:44.786Z","dependency_job_id":null,"html_url":"https://github.com/scientific-dev/node-set-theory","commit_stats":null,"previous_names":["scientific-guy/node-set-theory"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fnode-set-theory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fnode-set-theory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fnode-set-theory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scientific-dev%2Fnode-set-theory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scientific-dev","download_url":"https://codeload.github.com/scientific-dev/node-set-theory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235581560,"owners_count":19013096,"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":["javascript","maths","sets","typescript"],"created_at":"2024-11-25T17:38:55.765Z","updated_at":"2026-05-19T15:36:34.002Z","avatar_url":"https://github.com/scientific-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node Set Theory\n\nA Very brief wrapper for set calculations using Arrays...\n\n# Links\n- [Docs](https://github.com/scientific-dev/node-set-theory/wiki)\n- [Discord Support Server](https://discord.gg/FrduEZd)\n- [GitHub](https://github.com/scientific-dev/node-set-theory/)\n\n# Quick Example\n\n```js\nconst { union, intersect } = require('node-set-theory');\n\nlet set1 = [1, 2, 3];\nlet set2 = [4, 5, 6];\n\nconsole.log(intersect(union(set1, set2), set2)); // Returns [ 4, 5, 6 ]\n```\n\n## Quick Docs\n\n### Installation\n\nYou can install node-set-theory through npm. You can use Typescript for it too...\n\n```\nnpm install node-set-theory\n```\n\nIn your index file\n\n```js\nconst set = require('node-set-theory');\n```\n\n### Basic Methods\n\n```js\nconst { belongs } = require('node-set-theory');\n\n// The simple include() method\nbelongs([1, 2], 0); // Returns false\nbelongs([1, 2], 1); // Returns true.\n\n```\n\n### Calculation Methods\n\n```js\nconst { union, intersect, subtract } = require('node-set-theory');\n\nunion([1, 2], [3, 2]); // Will return [1, 2, 3]\nintersect([1, 2]. [3, 2]); // Will return [2]\nsubtract([1, 2], [3, 2]); // Will return [1]\nsubtract([3, 2], [1, 2]); // Will return [3]\n```\n\n### Verifying Methods\n\n```js\nconst { isNull, isProper, isEqual, isSubset, isProperSubset, overlaps } = require('node-set-theory');\n\n// Verify is the set empty aka null set\nisNull([]); // Will return false\nisNull([1]); // Will return true.\n\n// Simple method to find is the set is proper set or not\nisProper([null, 1, 2]); // Will return false because it has null\nisProper([1, 2, 3]); // Will return true. \n\n// Verify is the set equal to the second set\nisEqual([1, 0], [0, 1, 5]); // Will return false because the second set has extra element 5\nisEqual([1, 0], [0, 1]); // Will return true.\n\n// Method to find is the set are disjoint set or overlapping set\noverlaps([1, 2, 3], [4, 5, 6]); // Will return false because none of the elements same between the sets\noverlaps([1, 2, 3], [4, 3, 2]); // Will return true as 2 and 3 are common between those 2 sets\n\n// Method to verify is the set is the subset of the given sent\nisSubset([1, 2, 3], [1, 2]); // Will return true\nisProperSubset([1, 2, 3], [null, 2, 3]); // Will return false because it verifies the proper subset...\n```\n\n### Power Set Methods\n\n```js\nconst { subsets, properSubsets } = require('node-set-theory');\n\n// Method to get all subsets also known as the power set\nsubsets([1, 2, 3]);\n// Returns [ [], [ 1 ], [ 2 ], [ 2, 1 ], [ 3 ], [ 3, 1 ], [ 3, 2 ], [ 3, 2, 1 ] ]\n\n// Get all the proper subsets\nproperSubsets([1, 2, 3]);\n// Returns [ [ 1 ], [ 2 ], [ 2, 1 ], [ 3 ], [ 3, 1 ], [ 3, 2 ], [ 3, 2, 1 ] ]\n```\n\n### Types Methods\n\n```js\nconst { sizeType } = require('node-set-theory');\n\n// Will return 'empty', 'singleton' or 'many' based on the size of the set...\nsizeType([]); // Will return 'empty' which means null set\nsizeType([1]); // Will return 'singleton' which means it has only 1 element\nsizeType([1, 2, 3]); // Will return 'many' which means it has more than 1 element\n```\n\n### Shorthand Methods\n\n```js\nconst { n, P, proper } = require('node-set-theory');\n\n// Find the length of the array\nn([1, 2]); // Will return 2 as length\n\n// Get power set of the array\nP([1, 2, 3]); // Will return [ [], [ 1 ], [ 2 ], [ 2, 1 ], [ 3 ], [ 3, 1 ], [ 3, 2 ], [ 3, 2, 1 ] ]\n\n// Convert your set to proper set\nproper([null, [], 1, 0, 5]); // Will return [1, 5]\n```\n\n## Things need to be done\n\nThis package is at its extent but has some missing features to be done which you can try to contribute...\n\n- **Only Roster sets**: Yes the point is set builder form and the descriptive form cannot be used here. You can still use Roster form of sets. Example: `[1, 2, 3]`. The second problem with it is that you cannot use `{}` because of the traditional Javascript Arrays `[]` uses this kind of brackets...\n\n- **Advanced Calculations:** This package misses some advanced calculations with set which i don't know myself what are those? Incase if you feel that you know some, try to contribute in github!\n\n- **Representation of null:** So most of the people use `{}` or `∅` to represent null in maths but in this package represents null as `[]` and `null`...\n\n- **Shorthand Operations:** This package misses up lot of shorthand operations like the following. `(A U B) - B`. You have to do `subtract(union(A, B), B)` using this package. So it will be good to give us ideas or contribute in github to make shorthand operations...\n\n- **Universal Sets:** You cannot make like universal sets in this. This is possible to create but because of lack of developers, this feature might come in upcomming periods. Or you can try to contribute this feature!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscientific-dev%2Fnode-set-theory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscientific-dev%2Fnode-set-theory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscientific-dev%2Fnode-set-theory/lists"}