Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dbkaplun/unsplay

Compute a tree from an array of objects with IDs and parent IDs
https://github.com/dbkaplun/unsplay

Last synced: 28 days ago
JSON representation

Compute a tree from an array of objects with IDs and parent IDs

Awesome Lists containing this project

README

        

# unsplay [![Build Status](https://travis-ci.org/dbkaplun/unsplay.svg?branch=master)](https://travis-ci.org/dbkaplun/unsplay)
Compute a tree from an array of objects with IDs and parent IDs

## Installation
```shell
$ npm install unsplay
```

## Usage
```javascript
>> var unsplay = require('unsplay');
>> unsplay([{id: 0}, {id: 1, pid: 0}], 'id', 'pid');
[{
item: {id: 0},
children: [{
item: {id: 1, pid: 0},
children: []
}]
}]
```