1.0.1 • Published 3 years ago
nv-facutil-simple-nest v1.0.1
nv-facutil-simple-nest
- nv-facutil-simple-nest for only-one-type structure
install
- npm install nv-facutil-simple-nest
usage
example
const {
is_set_leaf,
is_array_leaf,
is_dict_leaf,
new_set,
new_array,
new_dict,
get_set_children,
get_array_children,
get_dict_children,
wfs_gen_engine,
flatten,
leaf_flatten,
nonleaf_flatten,
} = require("nv-facutil-simple-nest")
var o = {a:{x:1,y:2,z:3},b:{},c:100}
> dflatten(o)
Map(7) {
[] => { a: { x: 1, y: 2, z: 3 }, b: {}, c: 100 },
[ 'a' ] => { x: 1, y: 2, z: 3 },
[ 'b' ] => {},
[ 'c' ] => 100,
[ 'a', 'x' ] => 1,
[ 'a', 'y' ] => 2,
[ 'a', 'z' ] => 3
}
>
var o = [[1,2,3],[],100]
aflatten(o)
var o = new Set([new Set([1,2,3]),new Set(),new Set([100])])
sflatten(o)
var g = wfs_gen_engine(o,is_dict_leaf,get_dict_children)
var entries = Array.from(g)
entries.map(r=>r.pl)
entries.map(r=>r.o)
> entries.map(r=>r.pl)
[
[],
[ 'a' ],
[ 'b' ],
[ 'c' ],
[ 'a', 'x' ],
[ 'a', 'y' ],
[ 'a', 'z' ]
]
> entries.map(r=>r.o)
[
{ a: { x: 1, y: 2, z: 3 }, b: {}, c: 100 },
{ x: 1, y: 2, z: 3 },
{},
100,
1,
2,
3
]
>
> entries.map(r=>r.leaf)
[
false, false,
true, true,
true, true,
true
]
>
var o = [[1,2,3],[],100]
var g = wfs_gen_engine(o,is_array_leaf,get_array_children)
var entries = Array.from(g)
entries.map(r=>r.pl)
entries.map(r=>r.o)
> entries.map(r=>r.pl)
[
[], [ 0 ],
[ 1 ], [ 2 ],
[ 0, 0 ], [ 0, 1 ],
[ 0, 2 ]
]
> entries.map(r=>r.o)
[ [ [ 1, 2, 3 ], [], 100 ], [ 1, 2, 3 ], [], 100, 1, 2, 3 ]
>
> entries.map(r=>r.leaf)
[
false, false,
true, true,
true, true,
true
]
>
var o = new Set([new Set([1,2,3]),new Set(),new Set([100])])
var g = wfs_gen_engine(o,is_set_leaf,get_set_children)
var entries = Array.from(g)
entries.map(r=>r.pl)
entries.map(r=>r.o)
> entries.map(r=>r.pl)
[
[], [ 0 ],
[ 1 ], [ 2 ],
[ 0, 0 ], [ 0, 1 ],
[ 0, 2 ], [ 2, 0 ]
]
> entries.map(r=>r.o)
[
Set(3) { Set(3) { 1, 2, 3 }, Set(0) {}, Set(1) { 100 } },
Set(3) { 1, 2, 3 },
Set(0) {},
Set(1) { 100 },
1,
2,
3,
100
]
>
> entries.map(r=>r.leaf)
[
false, false,
true, true,
true, true,
true
]
>
API
LICENSE
- ISC