nv-set-subsets

subsets of Set

Usage no npm install needed!

<script type="module">
  import nvSetSubsets from 'https://cdn.skypack.dev/nv-set-subsets';
</script>

README

nv-set-subsets

  • nv-set-subsets is very simple util as subsets of Set

install

  • npm install nv-set-subsets

usage

example

const Subset = require('nv-set-subsets').Subset

> var subs = new Subset(1,2)
undefined
> subs
[1,2]
>
> var subs = new Subset(1,2)
undefined
> subs
[1,2]
> subs.add(3)
undefined
> subs
[1,2]
[3]
> subs.add(6,7,8)
undefined
> subs.subsets
Set { Set { 1, 2 }, Set { 3 }, Set { 6, 7, 8 } }
>
> subs.total
6
> subs.is_in_same_subset(6,8)
true
> subs.is_in_same_subset(6,9)
false
> subs.is_in_same_subset(1,7)
false
>
> subs.get_count(7)
3
> subs.get_subset(7)
Set { 6, 7, 8 }
>

> subs.rm(6)
undefined
> subs.subsets
Set { Set { 1, 2 }, Set { 3 }, Set { 7, 8 } }
>
> subs.add(9,7)
undefined
> subs
[1,2]
[3]
[7,8,9]
>
> subs.rm(3)
undefined
> subs.subsets
Set { Set { 1, 2 }, Set { 7, 8, 9 } }
>

subs.add(4,5)
> subs.subsets
Set { Set { 1, 2 }, Set { 4, 5 }, Set { 7, 8, 9 } }
>
> subs.add(2,7,10)
undefined
> subs.subsets
Set { Set { 1, 2, 7, 8, 9, 10 }, Set { 4, 5 } }

APIS

methods

subs.add                   subs.get_count             subs.get_subs
subs.get_subset            subs.is_in_same_subset     subs.rm     
subs.subsets
subs.total

LICENSE

  • ISC