source: node_modules/ramda-adjunct/es/internal/ap.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 775 bytes
Line 
1import { ap as apR, curryN, pathSatisfies, both, either } from 'ramda';
2import isFunction from '../isFunction';
3import * as fl from '../fantasy-land/mapping';
4var isFunctor = either(pathSatisfies(isFunction, ['map']), pathSatisfies(isFunction, [fl.map]));
5var isApply = both(isFunctor, either(pathSatisfies(isFunction, ['ap']), pathSatisfies(isFunction, [fl.ap])));
6var ap = curryN(2, function (applyF, applyX) {
7 // return original ramda `ap` if not Apply spec
8 if (!isApply(applyF) || !isApply(applyX)) {
9 return apR(applyF, applyX);
10 }
11 try {
12 // new version of `ap` starting from ramda version > 0.23.0
13 return applyF.ap(applyX);
14 } catch (e) {
15 // old version of `ap` till ramda version <= 0.23.0
16 return applyX.ap(applyF);
17 }
18});
19export default ap;
Note: See TracBrowser for help on using the repository browser.