set-operations
Javascript Set operations with ES6 Sets.
Installation
npm i set-operations
tests
npm run test
build
npm run build
modules
args
isSubset, isSuperSet: (arrA, arrB)
- arrA - Array
- arrB - Array
union, intersection, difference, symmetric difference: (arrA, arrB, returnAsArray)
- arrA - Array
- arrB - Array
- returnAsArray - boolean , default - false, if set true, returns the result as an array instead of a Set.
isSuperSet
Superset (A ⊇ B) : check if Arr A is superset of Arr B, i.e all elements of B are also elements of A.
; ;// true ;// false ;// true
isSubSet
Subset (A ⊆ B) : check if Arr A is subset of Arr B, i.e all elements of A are also elements of B.
; ;// true ;// true
union
Union (A ∪ B): create a set that contains the elements of both arr A and arr B.
; ; // Set { "rio", "delhi", "nairobi", "morocco", "algeria", "texas" }
intersection
Intersection (A ∩ B): create a set that contains those elements of Arr A that are also in Arr B.
; ; // Set { 21, 52 }
difference
Difference (A \ B): create a set that contains those elements of Arr A that are not in Arr B.
; ; // Set { 562, 223, 652, 1 }
symmetric difference
Symmetric Difference (A ∆ B): create a set of all elements which are in Arr A or Arr B but not both.
; ; // Set { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } // Set { "rises", "east", "sets", "west" }
License
MIT