[d24f17c] | 1 | import _curry3 from "./internal/_curry3.js";
|
---|
| 2 | import _dispatchable from "./internal/_dispatchable.js";
|
---|
| 3 | import _promap from "./internal/_promap.js";
|
---|
| 4 | import _xpromap from "./internal/_xpromap.js";
|
---|
| 5 | /**
|
---|
| 6 | * Takes two functions as pre- and post- processors respectively for a third function,
|
---|
| 7 | * i.e. `promap(f, g, h)(x) === g(h(f(x)))`.
|
---|
| 8 | *
|
---|
| 9 | * Dispatches to the `promap` method of the third argument, if present,
|
---|
| 10 | * according to the [FantasyLand Profunctor spec](https://github.com/fantasyland/fantasy-land#profunctor).
|
---|
| 11 | *
|
---|
| 12 | * Acts as a transducer if a transformer is given in profunctor position.
|
---|
| 13 | *
|
---|
| 14 | * @func
|
---|
| 15 | * @memberOf R
|
---|
| 16 | * @since v0.28.0
|
---|
| 17 | * @category Function
|
---|
| 18 | * @sig (a -> b) -> (c -> d) -> (b -> c) -> (a -> d)
|
---|
| 19 | * @sig Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d
|
---|
| 20 | * @param {Function} f The preprocessor function, a -> b
|
---|
| 21 | * @param {Function} g The postprocessor function, c -> d
|
---|
| 22 | * @param {Profunctor} profunctor The profunctor instance to be promapped, e.g. b -> c
|
---|
| 23 | * @return {Profunctor} The new profunctor instance, e.g. a -> d
|
---|
| 24 | * @see R.transduce
|
---|
| 25 | * @example
|
---|
| 26 | *
|
---|
| 27 | * const decodeChar = R.promap(s => s.charCodeAt(), String.fromCharCode, R.add(-8))
|
---|
| 28 | * const decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar))
|
---|
| 29 | * decodeString("ziuli") //=> "ramda"
|
---|
| 30 | *
|
---|
| 31 | * @symb R.promap(f, g, h) = x => g(h(f(x)))
|
---|
| 32 | * @symb R.promap(f, g, profunctor) = profunctor.promap(f, g)
|
---|
| 33 | */
|
---|
| 34 |
|
---|
| 35 | var promap =
|
---|
| 36 | /*#__PURE__*/
|
---|
| 37 | _curry3(
|
---|
| 38 | /*#__PURE__*/
|
---|
| 39 | _dispatchable(['fantasy-land/promap', 'promap'], _xpromap, _promap));
|
---|
| 40 |
|
---|
| 41 | export default promap; |
---|