ramda-adjunct
Version:
Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
19 lines • 781 B
JavaScript
import { ap as apR, curryN, pathSatisfies, both, either } from 'ramda';
import isFunction from '../isFunction.js';
import * as fl from '../fantasy-land/mapping.js';
var isFunctor = either(pathSatisfies(isFunction, ['map']), pathSatisfies(isFunction, [fl.map]));
var isApply = both(isFunctor, either(pathSatisfies(isFunction, ['ap']), pathSatisfies(isFunction, [fl.ap])));
var ap = curryN(2, function (applyF, applyX) {
// return original ramda `ap` if not Apply spec
if (!isApply(applyF) || !isApply(applyX)) {
return apR(applyF, applyX);
}
try {
// new version of `ap` starting from ramda version > 0.23.0
return applyF.ap(applyX);
} catch (e) {
// old version of `ap` till ramda version <= 0.23.0
return applyX.ap(applyF);
}
});
export default ap;