1.0.1 • Published 3 years ago

@jswork/next-traverse v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

next-traverse

Traverse object which has items key.

version license size download

installation

npm install -S @jswork/next-traverse

usage

import '@feizheng/next-traverse';

const data = {
  tagName:'div',
  children:[
    {
      tagName:'p',
      content:'Content1'
    },
    {
      tagName:'p',
      content:'Content2'
    }
  ]
};

// walk your object/array:
nx.traverse(data,(index, value, children)=>{
  console.log(children);
}, { itemsKey: 'children'});

options

nametypedefaultdescription
itemsKeystring/function'items'The target children key.
contextobjectnullThe loop context.
injectbooleanfalseIf inject independent and depth to the tree item.

license

Code released under the MIT license.