anabolicset

1.4.1 • Public • Published



You'll never use Set again...

AnabolicSet is built around the optional ability to customize item comparisons with a custom serializer. The uniqueness is guaranteed for the return value of the serializer.

This allows you to do things like:

const set1 = new AnabolicSet([{ id: 1 }, { id: 2 }, { id: 2 }], (obj) => obj.id) // <-- serializer
set1.values() // [{id: 1}, {id: 2}]

Featuring...

const set1 = new AnabolicSet([1, 2, 3, 4, 5])
const set2 = new AnabolicSet([2, 4])

set1.addAll(...[5, 6])
set1.values() // [1, 2, 3, 4, 5, 6]

set2.isSubsetOf(set1) // true
set1.isSupersetOf(set2) // true

set2.add(7)
set1.union(set2) // AnabolicSet [1, 2, 3, 4, 5, 6, 7]

Import

npm:

$ npm i anabolicset
import { AnabolicSet } from 'anabolicset/src/anabolicset'

cdn:

<script src="https://cdn.jsdelivr.net/gh/ColonelParrot/AnabolicSet@latest/src/anabolicset.min.js"></script>

documentation

Readme

Keywords

Package Sidebar

Install

npm i anabolicset

Weekly Downloads

3

Version

1.4.1

License

MIT

Unpacked Size

5.5 MB

Total Files

54

Last publish

Collaborators

  • colonelparrot