fancy-set
Constrained mixin that applies set-theoretic operations to set classes.
Installation
pnpm add fancy-set
Usage
Fancified versions of the native set class can be directly imported:
import { FancySet } from "fancy-set";
const myFancySet = new FancySet([1, 2, 3]);
const mySuperFancySet = new FancySet([1, 2, 3, 4, 5]);
mySuperFancySet.isSuperset(myFancySet); // true
TypeScript support
This module ships its own type definitions, so TypeScript is supported out of the box.
Custom sets
The fancify
mixin can be applied to custom set implementations:
import { fancify } from "fancy-set";
class MyCustomSet extends Set {
/** ... */
}
const MyFancyCustomSet = fancify(MyCustomSet);
Alternatively, custom set implementations can be derived from fancy sets:
import { fancify, FancySet } from "fancy-set";
class MyFancyCustomSet extends fancify(Set) {
/** ... */
}
// or
class MyFancyCustomSet extends FancySet {
/** ... */
}