Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install

$ npm install data-structure-conversion

Usage

const { list2tree } = require('data-structure-conversion');
const rawList = [
  { id: 1 },
  { id: 2, pid: 1 },
  { id: 3, pid: 2 },
  { id: 4 }
];

list2tree(rawList);
//=> 
[
  {
    id: 1,
    nodes: [
      {
        id: 2,
        pid: 1,
        nodes: [
          {
            id: 3,
            pid: 2
          }
        ]
      }
    ]
  },
  {
    id: 4
  }
]

API

list2tree(data[, key[, parentKey]])

About

Testing publish a package to npm

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages