source: node_modules/ramda/es/pipe.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import _arity from "./internal/_arity.js";
2import _pipe from "./internal/_pipe.js";
3import reduce from "./reduce.js";
4import tail from "./tail.js";
5/**
6 * Performs left-to-right function composition. The first argument may have
7 * any arity; the remaining arguments must be unary.
8 *
9 * In some libraries this function is named `sequence`.
10 *
11 * **Note:** The result of pipe is not automatically curried.
12 *
13 * @func
14 * @memberOf R
15 * @since v0.1.0
16 * @category Function
17 * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
18 * @param {...Function} functions
19 * @return {Function}
20 * @see R.compose
21 * @example
22 *
23 * const f = R.pipe(Math.pow, R.negate, R.inc);
24 *
25 * f(3, 4); // -(3^4) + 1
26 * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
27 * @symb R.pipe(f, g, h)(a)(b) = h(g(f(a)))(b)
28 */
29
30export default function pipe() {
31 if (arguments.length === 0) {
32 throw new Error('pipe requires at least one argument');
33 }
34
35 return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments)));
36}
Note: See TracBrowser for help on using the repository browser.