JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 310
  • Score
    100M100P100Q87219F
  • License MIT

Set Utilities for JavaScript

Package Exports

  • set-utilities
  • set-utilities/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (set-utilities) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Set Utilities

This library is a collection of utility functions that operate with JavaScript Sets.

Each function, as derived from Set Theory, is built to operate on n-ary sets by accepting variable arguments. Additionally, each function operates with the principals of immutability: none of the input sets are modified in the process or result of calculation.

difference:

The difference of two sets contains all the elements of the first set that are not contained in the second (or thereafter).

import { difference } from 'set-utilities';

const differenceAB = difference(setA, setB);
const differenceABC = difference(setA, setB, setC);

equivalence:

Sets are equivalent if they have the same cardinality, and there is a bijection between the values contained in each set.

import { equivalence } from 'set-utilities';

const isEquivalentAB = equivalence(setA, setB);
const isEquivalentABC = equivalence(setA, setB, setC);

intersection:

The intersection of two sets contains all the elements each contained in both of the sets.

import { intersection } from 'set-utilities';

const intersectionAB = intersection(setA, setB);
const intersectionABC = intersection(setA, setB, setC);

union:

The union of two sets contains all the elements contained in either set (or both sets).

import { union } from 'set-utilities';

const unionAB = union(setA, setB);
const unionABC = union(setA, setB, setC);

xor (symmetric difference):

The symmetric difference of two sets contains only the unique elements of each set.

import { xor } from 'set-utilities';

const xorAB = xor(setA, setB);
const xorABC = xor(setA, setB, setC);

sort:

An immutable sorting operation for sets.

import { sort } from 'set-utilities';

const sorted = sort(setA);
const sortedByComparator = sort(setA, comparatorFunction);