Package Exports
- arraylist-to-tree
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (arraylist-to-tree) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
arraylist-to-tree
A small library that converts Array of list to tree view
Installation
npm install arraylist-to-tree
Usage
const tree = require('arraylistTotree');
const list = [{
id: 1,
parentInt: 0
}, {
id: 2,
parentInt: 1
}, {
id: 3,
parentInt: 1
}, {
id: 4,
parentInt: 2
}, {
id: 5,
parentInt: 2
}];
Result
[{
"id": 1,
"parentInt": 0,
"children": [
{
"id": 2,
"parentInt": 1,
"children": [
{
"id": 4,
"parentInt": 2
}, {
"id": 5,
"parentInt": 2
}
]
}]
}]
Tests
npm test