UNPKG

js2flowchart

Version:

> Why? While I've been working on [Under-the-hood-ReactJS](https://github.com/Bogdan-Lyashenko/Under-the-hood-ReactJS) I spent enormous amount of time on creating schemes. Each change in code or flowchart affects all entire scheme instantly, forcing you t

15 lines 441 B
export var flatTree = function flatTree(tree) { var getBody = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (node) { return node.body; }; var flatList = []; [].concat(tree).forEach(function (node) { var body = getBody(node); if (body && body.length) { flatList = flatList.concat(node, flatTree(body, getBody)); } else { flatList.push(node); } }); return flatList; };