UNPKG

327 BJavaScriptView Raw
1const 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
9const fnOrValue = (fnOrVal, data) => (typeof fnOrVal === 'function' ? fnOrVal(data) : fnOrVal);
10const identity = x => x;
11
12module.exports = { either, fnOrValue, identity };