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
|
Rev | Line | |
---|
[d24f17c] | 1 | import { ap as apR, curryN, pathSatisfies, both, either } from 'ramda';
|
---|
| 2 | import isFunction from '../isFunction';
|
---|
| 3 | import * as fl from '../fantasy-land/mapping';
|
---|
| 4 | var isFunctor = either(pathSatisfies(isFunction, ['map']), pathSatisfies(isFunction, [fl.map]));
|
---|
| 5 | var isApply = both(isFunctor, either(pathSatisfies(isFunction, ['ap']), pathSatisfies(isFunction, [fl.ap])));
|
---|
| 6 | var 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 | });
|
---|
| 19 | export default ap; |
---|
Note:
See
TracBrowser
for help on using the repository browser.