npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

set-utilities

v1.5.7

Published

High performance set theory - functional utilities which operate on arbitrary input sets.

Downloads

1,251

Readme

set utilities

NPM Version MIT License FOSSA Status

Build & Test Job Scale Test Job Coverage

Install Size Zipped Size Language

High performance set theory.

This library is a collection of functional utilities from set theory, each of which operate on an arbitrary number of input sets.

Each function accepts variable arguments and operates with the principals of immutability: none of the input sets are modified in the process of calculation.

Set Operations:

difference: A ∖ B

The difference of sets contains all the elements of the first set, not contained in other sets.

difference visual

import { difference } from 'set-utilities';

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

intersection: A ∩ B

The intersection of sets contains all the elements each contained in every set.

intersection visual

import { intersection } from 'set-utilities';

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

union: A ∪ B

The union of sets contains all the elements each contained in any set.

union visual

import { union } from 'set-utilities';

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

symmetric difference (xor): A ∆ B

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

xor visual

import { xor } from 'set-utilities';

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

Set Comparisons:

equivalence: A ∼ B

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

equivalence visual

import { equivalence } from 'set-utilities';

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

disjoint: A ∩ B = ∅

Sets are disjoint if they have no elements in common.

disjoint visual

import { disjoint } from 'set-utilities';

const isDisjointAB = disjoint(setA, setB);
const isDisjointABC = disjoint(setA, setB, setC);

pairwise disjoint: A ∩ B ∩ C = ∅

A family of sets are pairwise disjoint if none of the sets share any elements in common.

pairwise disjoint visual

import { pairwiseDisjoint } from 'set-utilities';

const isPairwiseDisjointAB = pairwiseDisjoint(setA, setB);
const isPairwiseDisjointABC = pairwiseDisjoint(setA, setB, setC);

subset: A ⊆ B

A set is a subset of another if all of its elements are contained in the other set.

subset visual

import { subset } from 'set-utilities';

const isSubsetAB = subset(setA, setB);
const isSubsetABC = subset(setA, setB, setC);

proper subset: A ⊂ B

A set is a proper subset of another if all of its elements are contained in the other set, and it has a lower cardinality than the other set.

proper subset visual

import { properSubset } from 'set-utilities';

const isProperSubsetAB = properSubset(setA, setB);
const isProperSubsetABC = properSubset(setA, setB, setC);

superset: A ⊇ B

A set is a superset of another if it contains all the elements contained in the other set.

superset visual

import { superset } from 'set-utilities';

const isSupersetAB = superset(setA, setB);
const isSupersetABC = superset(setA, setB, setC);

proper superset: A ⊃ B

A set is a proper superset of another if it contains all the elements contained in the other set, and it has a greater cardinality than the other set.

proper superset visual

import { properSuperset } from 'set-utilities';

const isProperSupersetAB = properSuperset(setA, setB);
const isProperSupersetABC = properSuperset(setA, setB, setC);

Set Ordering:

sort: A ⇅

An immutable sorting operation for sets.

sort visual

import { sort } from 'set-utilities';

const sortedA = sort(setA);
const sortedB = sort(setB, compareFunction);