waltz-ng/client/common/siphon-utils.js
/**
 * Takes a predicate and returns a new function that can be used
 * as part of a reject step in a lodash chain.
 * The returned function has a property called `.results` which contains
 * all values which pass the predicate condition.
 *
 * @param predicate
 * @returns {function(*=): boolean}
 */
Takes a predicate and returns a new function that can be used
as part of a reject step in a lodash chain.
The returned function has a property called `.results` which contains
all values which pass the predicate condition.

@param predicate
@returns {function(*=): boolean}
Takes a predicate and returns a new function that can be used as part of a reject step in a lodash chain . The returned function has a property called ` . results ` which contains all values which pass the predicate condition . @param predicate @returns { function ( * = ) : boolean }
function mkSiphon(predicate) {
    if (_.isNil(predicate)){
        throw "Cannot create a siphon without a predicate";
    }
    if (!_.isFunction(predicate)){
        throw "Must be given a predicate that is a function";
    }
    const siphon = (d) => {
        if (predicate(d)){
            siphon.results.push(d);
            return true;
        } else {
            return false;
        }
    }
    siphon.results = [];
    siphon.hasResults = () => !_.isEmpty(siphon.results);
    return siphon;
}
function mkSiphon ( predicate ) { if ( _ . isNil ( predicate ) ) { throw "Cannot create a siphon without a predicate" ; } if ( ! _ . isFunction ( predicate ) ) { throw "Must be given a predicate that is a function" ; } const siphon = ( d ) => { if ( predicate ( d ) ) { siphon . results . push ( d ) ; return true ; } else { return false ; } } siphon . results = [ ] ; siphon . hasResults = ( ) => ! _ . isEmpty ( siphon . results ) ; return siphon ; }
Takes a predicate and returns a new function that can be used
 as part of a reject step in a lodash chain.
Takes a predicate and returns a new function that can be used as part of a reject step in a lodash chain .