mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 07:02:28 +03:00
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/promap.js
|
|
|
|
|
|
import _curry3 from './internal/_curry3.js';
|
|
import _dispatchable from './internal/_dispatchable.js';
|
|
import _promap from './internal/_promap.js';
|
|
import _xpromap from './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
|
|
* @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 = _curry3(_dispatchable(['fantasy-land/promap', 'promap'], _xpromap, _promap));
|
|
|
|
export default promap;
|