A library written in TypeScript implementing the mathematical branch known as set theory - a subset of discrete mathematics.
While there is a current proposal for adding new methods to the Set class, it is not formally recommended yet. This library provides functions to coincide with the Set
class, as standardized by the ECMAScript Language Specification.
npm install @neoncitylights/sets
const a = new Set<number>([1, 2, 3, 4]);
const b = new Set<number>([4, 5, 6, 7]);
getIntersection(a, b); // new Set<number>([4])
getUnion(a, b); // new Set<number>([1, 2, 3, 4, 5, 6, 7])
const c = new Set<string>(["hello", "world"]);
const d = new Set<string>(["hello"]);
isSupersetOf(c, d); // true
isSubsetOf(d, c); // true
Auto-generated API documentation is available.
fn
: # predicates.areSetsDisjoint<TElement>(a, b): boolean • sourcefn
: # predicates.areSetsEquivalent<TElement>(a, b): boolean • sourcefn
: # predicates.areSetsEqual<TElement>(a, b): boolean • sourcefn
: # predicates.isSubsetOf<TElement>(a, b): boolean • sourcefn
: # predicates.isSupersetOf<TElement>(a, b): boolean • sourcefn
: # predicates.isProperSubsetOf<TElement>(a, b): boolean • sourcefn
: # predicates.isProperSupersetOf<TElement>(a, b): boolean • source
fn
: # operations.getUnion<TElement>(a, b): Set<TElement> • sourcefn
: # operations.getIntersection<TElement>(a, b): Set<TElement> • sourcefn
: # operations.getDifference<TElement>(a, b): Set<TElement> • sourcefn
: # operations.getSymmetricDifference<TElement>(a, b): Set<TElement> • source
fn
: # similarity.getJaccardSimilarityCoefficient<TElement>(a, b): number • sourcefn
: # similarity.getLogDice<TElement>(a, b): number • sourcefn
: # similarity.getOverlapCoefficient<TElement>(a, b): number • sourcefn
: # similarity.getSorensenDiceCoefficient<TElement>(a, b): number • source
T
: # types.SetFunction<TElement, TResult> • sourceT
: # types.SetOperation<TElement> • sourceT
: # types.SetPredicate<TElement> • sourceT
: # types.SetSimilarity<TElement> • source
This library is licensed under the MIT license (LICENSE-MIT
or http://opensource.org/licenses/MIT).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions.