Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

45 строки
1.3 KiB

import composeK from "./composeK.js";
import reverse from "./reverse.js";
/**
* Returns the left-to-right Kleisli composition of the provided functions,
* each of which must return a value of a type supported by [`chain`](#chain).
*
* `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`.
*
* @func
* @memberOf R
* @since v0.16.0
* @category Function
* @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z)
* @param {...Function}
* @return {Function}
* @see R.composeK
* @deprecated since v0.26.0
* @example
*
* // parseJson :: String -> Maybe *
* // get :: String -> Object -> Maybe *
*
* // getStateCode :: Maybe String -> Maybe String
* const getStateCode = R.pipeK(
* parseJson,
* get('user'),
* get('address'),
* get('state'),
* R.compose(Maybe.of, R.toUpper)
* );
*
* getStateCode('{"user":{"address":{"state":"ny"}}}');
* //=> Just('NY')
* getStateCode('[Invalid JSON]');
* //=> Nothing()
* @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a)))
*/
export default function pipeK() {
if (arguments.length === 0) {
throw new Error('pipeK requires at least one argument');
}
return composeK.apply(this, reverse(arguments));
}