src/privates/_currier.js
function _currier (fn, arity, isRightCurry, isAutoCurry, argsHolder) {
    return function () {
        var holderLen = argsHolder.length;
        var argsLen = arguments.length;
        var newArgsLen = holderLen + (argsLen > 1 && isAutoCurry ? argsLen : 1);
        var newArgs = Array(newArgsLen);

        for (var i = 0; i < holderLen; i++) {
            newArgs[i] = argsHolder[i];
        }

        for (; i < newArgsLen; i++) {
            newArgs[i] = arguments[i - holderLen];
        }

        if (newArgsLen >= arity) {
            return fn.apply(this, isRightCurry ? newArgs.reverse() : newArgs);
        } else {
            return _currier(fn, arity, isRightCurry, isAutoCurry, newArgs);
        }
    };
}
function _currier (fn, arity, isRightCurry, isAutoCurry, argsHolder) {
    return function () {
        var holderLen = argsHolder.length;
        var argsLen = arguments.length;
        var newArgsLen = holderLen + (argsLen > 1 && isAutoCurry ? argsLen : 1);
        var newArgs = Array(newArgsLen);

        for (var i = 0; i < holderLen; i++) {
            newArgs[i] = argsHolder[i];
        }

        for (; i < newArgsLen; i++) {
            newArgs[i] = arguments[i - holderLen];
        }

        if (newArgsLen >= arity) {
            return fn.apply(this, isRightCurry ? newArgs.reverse() : newArgs);
        } else {
            return _currier(fn, arity, isRightCurry, isAutoCurry, newArgs);
        }
    };
}
function _currier ( fn , arity , isRightCurry , isAutoCurry , argsHolder ) { return function ( ) { var holderLen = argsHolder . length ; var argsLen = arguments . length ; var newArgsLen = holderLen + ( argsLen > 1 && isAutoCurry ? argsLen : 1 ) ; var newArgs = Array ( newArgsLen ) ; for ( var i = 0 ; i < holderLen ; i ++ ) { newArgs [ i ] = argsHolder [ i ] ; } for ( ; i < newArgsLen ; i ++ ) { newArgs [ i ] = arguments [ i - holderLen ] ; } if ( newArgsLen >= arity ) { return fn . apply ( this , isRightCurry ? newArgs . reverse ( ) : newArgs ) ; } else { return _currier ( fn , arity , isRightCurry , isAutoCurry , newArgs ) ; } } ; }
Used by curry functions to collect arguments until the arity is consumed,
then applies the original function.
@private
@param {Function} fn
@param {Number} arity
@param {Boolean} isRightCurry
@param {Boolean} isAutoCurry
@param {Array} argsHolder
@returns {Function}
Used by curry functions to collect arguments until the arity is consumed then applies the original function .