Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
chain-able-deps / dist / fp / pipe.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fromArgumentsToArray_1 = require("../cast/fromArgumentsToArray");
var pipeTwo_1 = require("./pipeTwo");
/**
 * Performs left-to-right function composition. The leftmost function may have
 * any arity; the remaining functions must be unary.
 * In some libraries this function is named `sequence`.
 *
 * @icon |
 * @func
 * @memberOf fp
 * @since v5.0.0
 * @category Function
 * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
 * @symb pipe(f, g, h)(a, b) = h(g(f(a, b)))
 * @extends fp/pipeTwo
 *
 * @param first function first
 * @param rest function next
 *
 * @see https://github.com/reactjs/redux/blob/master/src/compose.js
 * @see https://github.com/ramda/ramda/blob/master/src/compose.js
 * @see https://github.com/ramda/ramda/blob/master/src/pipe.js
 * @see https://github.com/ramda/ramda/blob/master/test/pipe.js
 *
 * @types fp
 * @tests fp/pipe
 *
 * @example
 *
 *      var f = R.pipe(Math.pow, R.negate, R.inc);
 *      f(3, 4); // -(3^4) + 1
 *
 * @example
 *
 *    var x = v => v + 'x'
 *    var y = v => v + 'y'
 *    var z = v => v + 'z'
 *
 *    const xyz = pipe(x, y, z)
 *    /// starts with w, adds x, then y, then z
 *    const wxyz = xyz('w')
 *    //=> 'wxyz'
 *
 */
function pipe(first) {
    var argumentz = [];
    for (var _i = 1; _i < arguments.length; _i++) {
        argumentz[_i - 1] = arguments[_i];
    }
    // @TODO: could move into pipeArray
    // could start from first, second? etc?
    // (isArray(first) ? first : argumentor.apply(null, arguments))
    var args = fromArgumentsToArray_1.default
        .apply(undefined, arguments)
        .slice(1)
        .reduce(pipeTwo_1.default);
    // .reduce((previous, next) => pipeTwo(previous, next))
    return pipeTwo_1.default(first, args);
}
exports.default = pipe;
//# sourceMappingURL=pipe.js.map