UNPKG

1.34 kBJavaScriptView Raw
1var composeK =
2/*#__PURE__*/
3require("./composeK");
4
5var reverse =
6/*#__PURE__*/
7require("./reverse");
8/**
9 * Returns the left-to-right Kleisli composition of the provided functions,
10 * each of which must return a value of a type supported by [`chain`](#chain).
11 *
12 * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`.
13 *
14 * @func
15 * @memberOf R
16 * @since v0.16.0
17 * @category Function
18 * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z)
19 * @param {...Function}
20 * @return {Function}
21 * @see R.composeK
22 * @deprecated since v0.26.0
23 * @example
24 *
25 * // parseJson :: String -> Maybe *
26 * // get :: String -> Object -> Maybe *
27 *
28 * // getStateCode :: Maybe String -> Maybe String
29 * const getStateCode = R.pipeK(
30 * parseJson,
31 * get('user'),
32 * get('address'),
33 * get('state'),
34 * R.compose(Maybe.of, R.toUpper)
35 * );
36 *
37 * getStateCode('{"user":{"address":{"state":"ny"}}}');
38 * //=> Just('NY')
39 * getStateCode('[Invalid JSON]');
40 * //=> Nothing()
41 * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a)))
42 */
43
44
45function pipeK() {
46 if (arguments.length === 0) {
47 throw new Error('pipeK requires at least one argument');
48 }
49
50 return composeK.apply(this, reverse(arguments));
51}
52
53module.exports = pipeK;
\No newline at end of file