1 | var _arity =
|
2 | /*#__PURE__*/
|
3 | require("./internal/_arity");
|
4 |
|
5 | var _curry2 =
|
6 | /*#__PURE__*/
|
7 | require("./internal/_curry2");
|
8 |
|
9 | var head =
|
10 | /*#__PURE__*/
|
11 | require("./head");
|
12 |
|
13 | var _reduce =
|
14 | /*#__PURE__*/
|
15 | require("./internal/_reduce");
|
16 |
|
17 | var tail =
|
18 | /*#__PURE__*/
|
19 | require("./tail");
|
20 |
|
21 | var identity =
|
22 | /*#__PURE__*/
|
23 | require("./identity");
|
24 | /**
|
25 | * Performs left-to-right function composition using transforming function. The first argument may have
|
26 | * any arity; the remaining arguments must be unary.
|
27 | *
|
28 | * **Note:** The result of pipeWith is not automatically curried. Transforming function is not used on the
|
29 | * first argument.
|
30 | *
|
31 | * @func
|
32 | * @memberOf R
|
33 | * @since v0.26.0
|
34 | * @category Function
|
35 | * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z)
|
36 | * @param {...Function} functions
|
37 | * @return {Function}
|
38 | * @see R.composeWith, R.pipe
|
39 | * @example
|
40 | *
|
41 | * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res));
|
42 | * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc])
|
43 | *
|
44 | * f(3, 4); // -(3^4) + 1
|
45 | * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, g(...args)))
|
46 | */
|
47 |
|
48 |
|
49 | var pipeWith =
|
50 | /*#__PURE__*/
|
51 | _curry2(function pipeWith(xf, list) {
|
52 | if (list.length <= 0) {
|
53 | return identity;
|
54 | }
|
55 |
|
56 | var headList = head(list);
|
57 | var tailList = tail(list);
|
58 | return _arity(headList.length, function () {
|
59 | return _reduce(function (result, f) {
|
60 | return xf.call(this, f, result);
|
61 | }, headList.apply(this, arguments), tailList);
|
62 | });
|
63 | });
|
64 |
|
65 | module.exports = pipeWith; |
\ | No newline at end of file |