@neoncitylights/sets

@neoncitylights/sets

License: MIT npm (scoped) Codecov GitHub Workflow Status (with event)

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.

Install

npm install @neoncitylights/sets

Usage

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

Documentation

Auto-generated API documentation is available.

API Reference

Predicates

  • fn: # predicates.areSetsDisjoint<*TElement*>(a, b): booleansource
  • fn: # predicates.areSetsEquivalent<*TElement*>(a, b): booleansource
  • fn: # predicates.areSetsEqual<*TElement*>(a, b): booleansource
  • fn: # predicates.isSubsetOf<*TElement*>(a, b): booleansource
  • fn: # predicates.isSupersetOf<*TElement*>(a, b): booleansource
  • fn: # predicates.isProperSubsetOf<*TElement*>(a, b): booleansource
  • fn: # predicates.isProperSupersetOf<*TElement*>(a, b): booleansource

Operations

  • fn: # operations.getUnion<*TElement*>(a, b): Set<*TElement*> • source
  • fn: # operations.getIntersection<*TElement*>(a, b): Set<*TElement*> • source
  • fn: # operations.getDifference<*TElement*>(a, b): Set<*TElement*> • source
  • fn: # operations.getSymmetricDifference<*TElement*>(a, b): Set<*TElement*> • source

Similarity measuring algorithms

  • fn: # similarity.getJaccardSimilarityCoefficient<*TElement*>(a, b): numbersource
  • fn: # similarity.getLogDice<*TElement*>(a, b): numbersource
  • fn: # similarity.getOverlapCoefficient<*TElement*>(a, b): numbersource
  • fn: # similarity.getSorensenDiceCoefficient<*TElement*>(a, b): numbersource

Types

  • T: # types.SetFunction<*TElement*, *TResult*> • source
  • T: # types.SetOperation<*TElement*> • source
  • T: # types.SetPredicate<*TElement*> • source
  • T: # types.SetSimilarity<*TElement*> • source

License

This library is licensed under the MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT).

Contribution

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.

Generated using TypeDoc