Repository URL to install this package:
|
Version:
6.0.4 ▾
|
"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