1 | const either = (fn, fa) => (...arg) => {
|
2 | try {
|
3 | return fn.apply(null, arg);
|
4 | } catch (e) {
|
5 | return typeof fa === 'function' ? fa(e) : fa;
|
6 | }
|
7 | };
|
8 |
|
9 | const fnOrValue = (fnOrVal, data) => (typeof fnOrVal === 'function' ? fnOrVal(data) : fnOrVal);
|
10 | const identity = x => x;
|
11 |
|
12 | module.exports = { either, fnOrValue, identity };
|