nv-set-nest

flat nested set

Usage no npm install needed!

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

README

nv-set-nest

  • nv-set-nest is a simple util for nested-set

install

  • npm install nv-set-nest

usage

example

const set_nest = require('nv-set-nest')
var st = new Set([1,new Set([2,3]),4,new Set([5,6,7]),8])
//Set { 1, Set { 2, 3 }, 4, Set { 5, 6, 7 }, 8 }
set_nest.flatten(st)
//Set { 1, 4, 8, 2, 3, 5, 6, 7 }

> to_ary(st)
[ 1, [ 2, 3 ], 4, [ 5, 6, 7 ], 8 ]
>
var arr = [ 1, [ 2, 3 ], 4, [ 5, 6, 7 ], 8 ]

> from_ary(arr)
Set(5) { 1, Set(2) { 2, 3 }, 4, Set(3) { 5, 6, 7 }, 8 }
>

var st = new Set([1,new Set([2,3]),4,new Set([5,6,7]),8])
> stringify(st)
'[1,[2,3],4,[5,6,7],8]'
>
> stringify(st)
'[1,[2,3],4,[5,6,7],8]'
>
> parse('[1,[2,3],4,[5,6,7],8]')
Set(5) { 1, Set(2) { 2, 3 }, 4, Set(3) { 5, 6, 7 }, 8 }
>

APIS

  • set_nest.flat_gen(st)
  • set_nest.flatten(st)
  • set_nest.to_ary(st)
  • set_nest.from_ary(st)
  • set_nest.parse(s)
  • set_nest.stringify(st)

LICENSE

  • ISC