src/http/get-index/ssr.js
/**
 * Search an array of node and its children for nodes passing a test function.
 *
 * @param test Function to test nodes on.
 * @param nodes Array of nodes to search.
 * @param recurse Also consider child nodes.
 * @param limit Maximum number of nodes to return.
 * @returns All nodes passing `test`.
 */
Search an array of node and its children for nodes passing a test function.
@param test Function to test nodes on.
@param nodes Array of nodes to search.
@param recurse Also consider child nodes.
@param limit Maximum number of nodes to return.
@returns All nodes passing `test`.
Search an array of node and its children for nodes passing a test function . @param test Function to test nodes on . @param nodes Array of nodes to search . @param recurse Also consider child nodes . @param limit Maximum number of nodes to return . @returns All nodes passing ` test ` .
function find(test, nodes, recurse, limit) {
  var result = [];
  for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
    var elem = nodes_1[_i];
    if (test(elem)) {
      result.push(elem);
      if (--limit <= 0)
      break;
    }
    if (recurse && domhandler_1$3.hasChildren(elem) && elem.children.length > 0) {
      var children = find(test, elem.children, recurse, limit);
      result.push.apply(result, children);
      limit -= children.length;
      if (limit <= 0)
      break;
    }
  }
  return result;
}
function find ( test , nodes , recurse , limit ) { var result = [ ] ; for ( var _i = 0 , nodes_1 = nodes ; _i < nodes_1 . length ; _i ++ ) { var elem = nodes_1 [ _i ] ; if ( test ( elem ) ) { result . push ( elem ) ; if ( -- limit <= 0 ) break ; } if ( recurse && domhandler_1$3 . hasChildren ( elem ) && elem . children . length > 0 ) { var children = find ( test , elem . children , recurse , limit ) ; result . push . apply ( result , children ) ; limit -= children . length ; if ( limit <= 0 ) break ; } } return result ; }
Search an array of node and its children for nodes passing a test function.
Search an array of node and its children for nodes passing a test function .