
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@fatso83/set-operations
Advanced tools
Fork of indrajaala's package with added support for native Sets
Javascript set operations with Arrays, Objects and Sets.
npm i set-operations
npm run test
npm run build
isSubset, isSuperSet: (A, B)
returns boolean
union, intersection, difference, symmetric difference: (A, B)
returns Array | object | Set
Superset (A ⊇ B) : check if A is superset of B, i.e all elements of B are also elements of A.
import {isSuperSet} from "set-operations";
isSuperSet([1, 8, 3, 5], [3, 8]);
// true
isSuperSet([1, 8, 3, 5], [3, 9]);
// false
isSuperSet(new Set(['apple', 'orange', 'banana']), new Set(['banana']);
// true
isSuperSet({id:'xyz', name:"john doe",age:59, work:"janitor"},{id:'xyz', work:"janitor"});
// true
isSuperSet({id:'xyz', name:"john doe",age:59, work:"janitor"},{id:'xyz', work:"janitor", likes:"football"});
// false
Subset (A ⊆ B) : check if A is subset of B, i.e all elements of A are also elements of B.
import {isSubSet} from "set-operations";
isSubSet([4, 5], [1, 9, 4, 8, 34, 43, 5]);
// true
isSubSet(["red", "blue"], ["violet", "indigo", "blue", "green", "yellow", "orange", "red"]);
// true
isSubSet({id:'xyz', work:"janitor"},{id:'xyz', name:"john doe",age:59, work:"janitor"})
//true
isSubSet({a:1,b:2,c:3},{b:2,c:3});
//false
Union (A ∪ B): create a Arr/obj that contains the elements of both A and B.
import {union} from "set-operations";
union(["rio", "delhi", "nairobi"], ["morocco", "algeria", "texas"]);
// [ "rio", "delhi", "nairobi", "morocco", "algeria", "texas" ]
union({firstname:"john", lastname:"doe"},{age:59, hobbies:["fishing", "cycling"]})
// {firstname:"john",lastname:"doe",age:59,hobbies:["fishing", "cycling"]}
note:for objects, union puts the elements of A and elements of B in to a new object - {...A, ...B,}, if the keys of elements in both A and B are same then the elements of B replaces elements of A.
Intersection (A ∩ B): create a Arr/obj that contains those elements of A that are also in B.
import {intersection} from "set-operations";
intersection([67, 21, 52, 78, 32, 321, 98, 97], [342, 52, 63, 89, 21]);
// [ 21, 52 ]
intersection({a: {a: 1, b: {c: 2,d:3}}, b: 2, c: 3, d: 4, e: 5},
{e: 5, f: 6, c: 3, a: {a: 1, b: {c: 2, d: 3}}}
)
//{ a: { a: 1, b: { c: 2, d: 3 } }, c: 3, e: 5 }
Difference (A \ B): create a Arr/obj that contains those elements of A that are not in B.
import {difference} from "set-operations";
difference([43, 562, 52, 223, 652, 1], [43, 42, 524, 542, 100, 52]);
// [ 562, 223, 652, 1 ]
difference({a: {a: 1, b: {c: 2,d:3}}, b: 2, c: 3, d: 4, e: 5},
{e: 5, f: 6, c: 3, a: {a: 1, b: {c: 2, d: 3}}}
)
// { b: 2, d: 4 }
Symmetric Difference (A ∆ B): create a Arr/obj of all elements which are in A or B but not both.
import {symmetricDifference} from "set-operations";
symmetricDifference([0, 1, 2, 3, 4], [5, 6, 7, 8, 9]);
// [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
symmetricDifference(["sun", "rises", "in", "the", "east"], ["sun", "sets", "in", "the", "west"])
// Set [ "rises", "east", "sets", "west" ]
symmetricDifference({a: {a: 1, b: {c: 2,d:3}}, b: 2, c: 3, d: 4, e: 5},
{e: 5, f: 6, c: 3, a: {a: 1, b: {c: 2, d: 3}}}
)
//{ b: 2, d: 4, f: 6 }
note:for objects, symmetric difference performs difference on A to B and then B to A and puts the elements in to a new object - {...difference(A, B), ...difference(B, A)}, if the keys of elements in both A and B are same then the elements of B replaces elements of A.
symmetricDifference({star:"sun",does:"rises",direction:"east"},
{star:"sun", does:"sets",direction:"west"}
)
//{does:"sets", direction:"west"});
MIT
FAQs
Javascript Set operations
We found that @fatso83/set-operations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.