Given a flat array of objects linked to one another, it will nest them recursively
const comments = [ { id: 1, comment_id: null }, { id: 2, comment_id: 1 }, { id: 3, comment_id: 1 }, { id: 4, comment_id: 2 }, { id: 5, comment_id: 4 }];nest(comments, "comment_id"); // [{ id: 1, comment_id: null, children: [...] }]
Optional
Generated using TypeDoc
Given a flat array of objects linked to one another, it will nest them recursively
Example