nv-facutil-rid-pool
v1.0.5
Published
nv-facutil-rid-local ======================= - small fixed layer nest id pool - for size \< 100000
Downloads
3
Readme
nv-facutil-rid-local
- small fixed layer nest id pool
- for size < 100000
install
- npm install nv-facutil-rid-local
usage
const {creat,load,dump} = require("nv-facutil-rid-local");
example
var pool = creat(["uname","utoken","usess"])
/*
> pool.types
[ 'uname', 'utoken', 'usess' ]
>
*/
var id = pool.addrt();
pool.id2typ(id);
/*
> pool.id2typ(id)
'uname'
*/
var cid = pool.addch(id);
pool.id2typ(cid)
/*
> pool.id2typ(cid)
'utoken'
*/
id;
cid;
pool.addch(id);
pool.addch(id);
pool.addch(id);
/*
> id;
'uhjbgrikguhcmbkclbngxkdomyfhfkgcykth'
> cid;
'avjgztjcojwddhiybsacdrtoqalihclelahk'
> pool.addch(id);
'ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg'
> pool.addch(id);
'jfedxwolxglatgfjjqhzxqijnlgawbbglldg'
> pool.addch(id);
'sijidfqdkgkzfbkazpiaefiqjhshsdqulqci'
>
*/
pool.chcnt(id)
//4
pool.chs(id)
/*
[
'avjgztjcojwddhiybsacdrtoqalihclelahk',
'ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg',
'jfedxwolxglatgfjjqhzxqijnlgawbbglldg',
'sijidfqdkgkzfbkazpiaefiqjhshsdqulqci'
]
*/
var child0_of_cid = pool.addch(cid)
pool.id2typ(child0_of_cid)
/*
> pool.id2typ(child0_of_cid)
'usess'
>
*/
var child1_of_cid = pool.addch(cid)
child0_of_cid;
child1_of_cid;
/*
> child0_of_cid;
'zardhwzukpwreklitopbhjbgbqyisnkttcmd'
> child1_of_cid;
'mcahxoigvixehbjnaqellwvanexffschrbva'
>
*/
pool.dict(id)
/*
> pool.dict(id)
{
avjgztjcojwddhiybsacdrtoqalihclelahk: {
zardhwzukpwreklitopbhjbgbqyisnkttcmd: null,
mcahxoigvixehbjnaqellwvanexffschrbva: null
},
ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg: {},
jfedxwolxglatgfjjqhzxqijnlgawbbglldg: {},
sijidfqdkgkzfbkazpiaefiqjhshsdqulqci: {}
}
>
*/
pool.pr(cid) === id
//true
pool.plances(child0_of_cid)
/*
> pool.plances(child0_of_cid)
[
'uhjbgrikguhcmbkclbngxkdomyfhfkgcykth',
'avjgztjcojwddhiybsacdrtoqalihclelahk',
'zardhwzukpwreklitopbhjbgbqyisnkttcmd'
]
> id
'uhjbgrikguhcmbkclbngxkdomyfhfkgcykth'
>
*/
dump(pool)
/*
{
uhjbgrikguhcmbkclbngxkdomyfhfkgcykth: {
avjgztjcojwddhiybsacdrtoqalihclelahk: {
zardhwzukpwreklitopbhjbgbqyisnkttcmd: null,
mcahxoigvixehbjnaqellwvanexffschrbva: null
},
ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg: {},
jfedxwolxglatgfjjqhzxqijnlgawbbglldg: {},
sijidfqdkgkzfbkazpiaefiqjhshsdqulqci: {}
}
}
>
*/
var rt2 = pool.addrt();
rt2;
dump(pool);
/*
{
uhjbgrikguhcmbkclbngxkdomyfhfkgcykth: {
avjgztjcojwddhiybsacdrtoqalihclelahk: {
zardhwzukpwreklitopbhjbgbqyisnkttcmd: null,
mcahxoigvixehbjnaqellwvanexffschrbva: null
},
ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg: {},
jfedxwolxglatgfjjqhzxqijnlgawbbglldg: {},
sijidfqdkgkzfbkazpiaefiqjhshsdqulqci: {}
},
gamtanyfclimbkgfisiumznnzhslvcehhxej: {}
}
*/
child0_of_cid;
pool.del_id_and_empty_ances(child0_of_cid);
/*
> dump(pool)
{
uhjbgrikguhcmbkclbngxkdomyfhfkgcykth: {
avjgztjcojwddhiybsacdrtoqalihclelahk: { mcahxoigvixehbjnaqellwvanexffschrbva: null },
ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg: {},
jfedxwolxglatgfjjqhzxqijnlgawbbglldg: {},
sijidfqdkgkzfbkazpiaefiqjhshsdqulqci: {}
},
gamtanyfclimbkgfisiumznnzhslvcehhxej: {}
}
>
*/
child1_of_cid;
pool.del_id_and_empty_ances(child1_of_cid); //
/*
> dump(pool)
{
uhjbgrikguhcmbkclbngxkdomyfhfkgcykth: {
ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg: {},
jfedxwolxglatgfjjqhzxqijnlgawbbglldg: {},
sijidfqdkgkzfbkazpiaefiqjhshsdqulqci: {}
},
gamtanyfclimbkgfisiumznnzhslvcehhxej: {}
}
>
*/
var dumped = {
uhjbgrikguhcmbkclbngxkdomyfhfkgcykth: {
avjgztjcojwddhiybsacdrtoqalihclelahk: {
zardhwzukpwreklitopbhjbgbqyisnkttcmd: null,
mcahxoigvixehbjnaqellwvanexffschrbva: null
},
ykthrmdkjwtxkmvhiwssyudsbjefanhybdwg: {},
jfedxwolxglatgfjjqhzxqijnlgawbbglldg: {},
sijidfqdkgkzfbkazpiaefiqjhshsdqulqci: {}
},
gamtanyfclimbkgfisiumznnzhslvcehhxej: {}
}
var pool2 = load(dumped,["uname","utoken","usess"])
METHODS
pool._chdict pool._del pool.add_nest pool.addch pool.addrt pool.chcnt
pool.chs pool.constructor pool.del pool.del_id_and_empty_ances pool.dict pool.exist
pool.plexist
pool.get_desc pool.get_lyr pool.get_roots pool.id2tid pool.id2typ pool.is_empty_non_leaf
pool.is_leaf pool.is_rt pool.plances pool.pr pool.tid2id pool.tid2typ
pool.types
APIS
{
creat: [Function: creat],
load: [Function: load],
dump: [Function: dump]
}
LICENSE
- ISC