episcope
Version:
ECMAScript scope analyzer
17 lines (13 loc) • 389 B
JavaScript
;
function concat(left, right) {
return [].concat(left, right)
}
function expand(array, f) {
return array.map(f).reduce(concat, [])
}
function tree(form, isBranch, nodes) {
function traversable(node) { return tree(node, isBranch, nodes) }
var children = isBranch(form) ? expand(nodes(form), traversable) : []
return [form].concat(children)
}
module.exports = tree