simplify-tree-nodes
Replace child nodes' keys with top level parent node's key by given tree
Last updated a year ago by rehnskiold .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install simplify-tree-nodes 
SYNC missed versions from official npm registry.

simplify-tree-nodes

Replace child nodes' keys with top level parent node's key by given tree.

Example

import simplifyTreeNodes from 'simplify-tree-nodes'

const treeData = [
  {
    key: "0-0",
    children: [
      {
        key: "0-0-0"
      },
      {
        key: "0-0-1"
      }
    ]
  },
  {
    key: "0-1",
    children: [
      {
        key: "0-1-0"
      },
      {
        key: "0-1-1"
      },
      {
        key: "0-1-2",
        children: [
          {
            key: "0-1-2-0"
          },
          {
            key: "0-1-2-1"
          }
        ]
      }
    ]
  }
];

const childKeys = ["0-0-0", "0-1-0", "0-1-1", "0-1-2-0", "0-1-2-1"];

const keys = simplifyTreeNodes(childKeys, treeData);

// keys: ['0-0-0', '0-1']

Current Tags

  • 0.1.3                                ...           latest (a year ago)

3 Versions

  • 0.1.3                                ...           a year ago
  • 0.1.2                                ...           a year ago
  • 0.1.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |