ramda
Version:
A practical functional library for JavaScript programmers.
35 lines • 1.61 kB
JavaScript
var _curry3 = /*#__PURE__*/require("./internal/_curry3.js");
var _dispatchable = /*#__PURE__*/require("./internal/_dispatchable.js");
var _promap = /*#__PURE__*/require("./internal/_promap.js");
var _xpromap = /*#__PURE__*/require("./internal/_xpromap.js");
/**
* Takes two functions as pre- and post- processors respectively for a third function,
* i.e. `promap(f, g, h)(x) === g(h(f(x)))`.
*
* Dispatches to the `promap` method of the third argument, if present,
* according to the [FantasyLand Profunctor spec](https://github.com/fantasyland/fantasy-land#profunctor).
*
* Acts as a transducer if a transformer is given in profunctor position.
*
* @func
* @memberOf R
* @since v0.28.0
* @category Function
* @sig (a -> b) -> (c -> d) -> (b -> c) -> (a -> d)
* @sig Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d
* @param {Function} f The preprocessor function, a -> b
* @param {Function} g The postprocessor function, c -> d
* @param {Profunctor} profunctor The profunctor instance to be promapped, e.g. b -> c
* @return {Profunctor} The new profunctor instance, e.g. a -> d
* @see R.transduce
* @example
*
* const decodeChar = R.promap(s => s.charCodeAt(), String.fromCharCode, R.add(-8))
* const decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar))
* decodeString("ziuli") //=> "ramda"
*
* @symb R.promap(f, g, h) = x => g(h(f(x)))
* @symb R.promap(f, g, profunctor) = profunctor.promap(f, g)
*/
var promap = /*#__PURE__*/_curry3( /*#__PURE__*/_dispatchable(['fantasy-land/promap', 'promap'], _xpromap, _promap));
module.exports = promap;