1 | var _arity =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_arity");
|
4 |
|
5 | var _pipe =
|
6 | /*#__PURE__*/
|
7 | require("./internal/_pipe");
|
8 |
|
9 | var reduce =
|
10 | /*#__PURE__*/
|
11 | require("./reduce");
|
12 |
|
13 | var tail =
|
14 | /*#__PURE__*/
|
15 | require("./tail");
|
16 | /**
|
17 | * Performs left-to-right function composition. The first argument may have
|
18 | * any arity; the remaining arguments must be unary.
|
19 | *
|
20 | * In some libraries this function is named `sequence`.
|
21 | *
|
22 | * **Note:** The result of pipe is not automatically curried.
|
23 | *
|
24 | * @func
|
25 | * @memberOf R
|
26 | * @since v0.1.0
|
27 | * @category Function
|
28 | * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
|
29 | * @param {...Function} functions
|
30 | * @return {Function}
|
31 | * @see R.compose
|
32 | * @example
|
33 | *
|
34 | * const f = R.pipe(Math.pow, R.negate, R.inc);
|
35 | *
|
36 | * f(3, 4); // -(3^4) + 1
|
37 | * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
|
38 | */
|
39 |
|
40 |
|
41 | function pipe() {
|
42 | if (arguments.length === 0) {
|
43 | throw new Error('pipe requires at least one argument');
|
44 | }
|
45 |
|
46 | return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments)));
|
47 | }
|
48 |
|
49 | module.exports = pipe; |
\ | No newline at end of file |