function findOne(test, nodes, recurse) {
    if (recurse === void 0) { recurse = true; }
    var elem = null;
    for (var i = 0; i < nodes.length && !elem; i++) {
        var checked = nodes[i];
        if (!(0, domhandler_1.isTag)(checked)) {
            continue;
        }
        else if (test(checked)) {
            elem = checked;
        }
        else if (recurse && checked.children.length > 0) {
            elem = findOne(test, checked.children, true);
        }
    }
    return elem;
}
/**
 * Finds one element in a tree that passes a test.
 *
 * @category Querying
 * @param test Function to test nodes on.
 * @param nodes Array of nodes to search.
 * @param recurse Also consider child nodes.
 * @returns The first child node that passes `test`.
 */
Finds one element in a tree that passes a test.
@category Querying
@param test Function to test nodes on.
@param nodes Array of nodes to search.
@param recurse Also consider child nodes.
@returns The first child node that passes `test`.
Finds one element in a tree that passes a test . @category Querying @param test Function to test nodes on . @param nodes Array of nodes to search . @param recurse Also consider child nodes . @returns The first child node that passes ` test ` .
function findOne(test, nodes, recurse) {
    if (recurse === void 0) { recurse = true; }
    var elem = null;
    for (var i = 0; i < nodes.length && !elem; i++) {
        var checked = nodes[i];
        if (!(0, domhandler_1.isTag)(checked)) {
            continue;
        }
        else if (test(checked)) {
            elem = checked;
        }
        else if (recurse && checked.children.length > 0) {
            elem = findOne(test, checked.children, true);
        }
    }
    return elem;
}
function findOne ( test , nodes , recurse ) { if ( recurse === void 0 ) { recurse = true ; } var elem = null ; for ( var i = 0 ; i < nodes . length && ! elem ; i ++ ) { var checked = nodes [ i ] ; if ( ! ( 0 , domhandler_1 . isTag ) ( checked ) ) { continue ; } else if ( test ( checked ) ) { elem = checked ; } else if ( recurse && checked . children . length > 0 ) { elem = findOne ( test , checked . children , true ) ; } } return elem ; }
Finds one element in a tree that passes a test.
Finds one element in a tree that passes a test .