pipeK.js•1.14 kB
var composeK = require('./composeK');
var reverse = require('./reverse');
/**
* 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(R.chain(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)) -> (m a -> m z)
* @param {...Function}
* @return {Function}
* @see R.composeK
* @example
*
* // parseJson :: String -> Maybe *
* // get :: String -> Object -> Maybe *
*
* // getStateCode :: Maybe String -> Maybe String
* var getStateCode = R.pipeK(
* parseJson,
* get('user'),
* get('address'),
* get('state'),
* R.compose(Maybe.of, R.toUpper)
* );
*
* getStateCode(Maybe.of('{"user":{"address":{"state":"ny"}}}'));
* //=> Just('NY')
* getStateCode(Maybe.of('[Invalid JSON]'));
* //=> Nothing()
*/
module.exports = function pipeK() {
return composeK.apply(this, reverse(arguments));
};