examples/ecmascript/es5.js
function flattenIterNodes(nodes) {
  var result = [];
  for (var i = 0; i < nodes.length; ++i) {
    if (nodes[i]._node.ctorName === '_iter') {
      result.push.apply(result, flattenIterNodes(nodes[i].children));
    } else {
      result.push(nodes[i]);
    }
  }
  return result;
}
function flattenIterNodes(nodes) {
  var result = [];
  for (var i = 0; i < nodes.length; ++i) {
    if (nodes[i]._node.ctorName === '_iter') {
      result.push.apply(result, flattenIterNodes(nodes[i].children));
    } else {
      result.push(nodes[i]);
    }
  }
  return result;
}
function flattenIterNodes ( nodes ) { var result = [ ] ; for ( var i = 0 ; i < nodes . length ; ++ i ) { if ( nodes [ i ] . _node . ctorName === '_iter' ) { result . push . apply ( result , flattenIterNodes ( nodes [ i ] . children ) ) ; } else { result . push ( nodes [ i ] ) ; } } return result ; }
Take an Array of nodes, and whenever an _iter node is encountered, splice in its recursively-flattened children instead.
Take an Array of nodes and whenever an _iter node is encountered splice in its recursively - flattened children instead .