npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nv-data-tree-csp-json

v1.0.12

Published

json-relation-tree

Downloads

3

Readme

nv-data-tree-csp-json

  • nv-data-tree-csp-json
  • json relation tree,support such as: parent,sibling....

install

  • npm install nv-data-tree-csp-json

usage

    const Forest = require('nv-data-tree-csp-forest');
      
    const {
        creat_undefined,
        creat_null,
        creat_true,
        creat_false,
        creat_str,
        creat_number,
        creat_ary,
        creat_obj,
        creat_external,
        creat_ref,
        is_jleaf,
        load_from_json,
    } = require("nv-data-tree-csp-json");

    load_from_json(J,forest=undefined,max_size=10000)

    //max_size default 10000(for small-size json), if larger than 1500000, speed low
    //   

perf

    /*

     nv-data-tree-csp-json# ls -l WORKDIR/TEST/ | egrep linux
     -rw-r--r-- 1 root root 34474647 Feb 28 12:47 linux-path.dict
     nv-data-tree-csp-json#


    // 160_0000  nodes

    > forest
    Forest {
      fid: '986368f3-c93f-4ac8-b0d9-cc4975b025dd',
      max_size: 2000000,
      idpool: { minid_: 1, maxid_: 2000000, used_: 1604477, lefted_: 395523 }
    }
    >

    > rt.$sdfs_.length
    1604477
    >
    > process.memoryUsage()
    {
      rss: 519315456,
      heapTotal: 455655424,
      heapUsed: 436544960,
      external: 1080249,
      arrayBuffers: 24785
    }
    >

    nv-file-reader# free
                  total        used        free      shared  buff/cache   available
    Mem:        2014880      666604      959736          64      388540     1190408
    Swap:       1970172      103572     1866600
    nv-file-reader#

    function tst() {
       let now = (new Date).getTime();
       let c =0
       let g = rt.$gen_sdfs_next();
       for(let each of g) {
           c = c+1
       }
       console.log(c);
       console.log((new Date).getTime() - now)
    }
    > tst()
    1604477
    282

    */

from_json

    var j = {
        undef: undefined,
        null: null,
        n1: 1,
        n2: 2,
        n3: 3,
        t: true,
        f: false,
        ary: [ 'a', 'b', 'c' ]
    }
    var [nd,forest] = load_from_json(j)

    > nd.show()
    {
      undef: undefined,
      null: null,
      n1: 1,
      n2: 2,
      n3: 3,
      t: true,
      f: false,
      ary: [...<3 unshow>...]
    }
   > nd.get('ary').show()
   [ "a", "b", "c" ]
   > nd
   {
     undef: undefined,
     null: null,
     n1: 1,
     n2: 2,
     n3: 3,
     t: true,
     f: false,
     ary: [ "a", "b", "c" ]
   }
   >
   > nd.json()
   {
     undef: undefined,
     null: null,
     n1: 1,
     n2: 2,
     n3: 3,
     t: true,
     f: false,
     ary: [ 'a', 'b', 'c' ]
   }
   >
   > nd.stringify()
   '{"null":null,"n1":1,"n2":2,"n3":3,"t":true,"f":false,["a","b","c"]}'
   > nd.get('ary')
   [ 'a', 'b', 'c' ]
   >
   > nd.get('ary').get(1)
   'b'
   > nd.get('ary').get(1).$parent_
   [ 'a', 'b', 'c' ]
   >       

    var forest = new Forest(10000);  //10000 max-supported nodes, must < 2**29


    var o = creat_obj(forest)
    o.show()
    o.append_undefined('undef')
    o.append_null('null')
    o.append_number("n1",1)
    o.append_number("n2",2)
    o.append_number("n3",3)
    o.append_true("t")
    o.append_false("f")

    o.append_ary("ary")
    var ary = o.get('ary')
    ary.show()
    ary.append_str("a")
    ary.append_str("b")
    ary.append_str("c")

    > o
    {
      undef: undefined,
      null: null,
      n1: 1,
      n2: 2,
      n3: 3,
      t: true,
      f: false,
      ary: [ 'a', 'b', 'c' ]
    }
    >

> o.get('ary').get(1)
b
> o.get('ary').get(1).$parent_
[ a, b, c ]
>

> o.stringify()
'{"null":null,"n1":1,"n2":2,"n3":3,"t":true,"f":false,["a","b","c"]}'
>


> o.json()
{
  undef: undefined,
  null: null,
  n1: 1,
  n2: 2,
  n3: 3,
  t: true,
  f: false,
  ary: [ 'a', 'b', 'c' ]
}
>

> o.$sedfs_
[
  [
    {
      undef: undefined,
      null: null,
      n1: 1,
      n2: 2,
      n3: 3,
      t: true,
      f: false,
      ary: [Array]
    },
    'open'
  ],
  [ undefined, 'open' ],
  [ undefined, 'close' ],
  [ null, 'open' ],
  [ null, 'close' ],
  [ 1, 'open' ],
  [ 1, 'close' ],
  [ 2, 'open' ],
  [ 2, 'close' ],
  [ 3, 'open' ],
  [ 3, 'close' ],
  [ true, 'open' ],
  [ true, 'close' ],
  [ false, 'open' ],
  [ false, 'close' ],
  [ [ a, b, c ], 'open' ],
  [ a, 'open' ],
  [ a, 'close' ],
  [ b, 'open' ],
  [ b, 'close' ],
  [ c, 'open' ],
  [ c, 'close' ],
  [ [ 'a', 'b', 'c' ], 'close' ],
  [
    {
      undef: undefined,
      null: null,
      n1: 1,
      n2: 2,
      n3: 3,
      t: true,
      f: false,
      ary: [Array]
    },
    'close'
  ]
]
>    

proxy

> o.$_.ary
Proxy [
  [ 'a', 'b', 'c' ],
  { get: [Function: get], set: [Function: set] }
]
> o.$_.ary[1]
Proxy [ 'b', { get: [Function: get] } ]
>
> o.$_.ary[1] = 'BBB'
'BBB'
> o
{
  undef: undefined,
  null: null,
  n1: 1,
  n2: 2,
  n3: 3,
  t: true,
  f: false,
  ary: [ 'a', 'BBB', 'c' ]
}
>    

LICENSE

  • ISC