UNPKG

843 BJavaScriptView Raw
1var _isArray =
2/*#__PURE__*/
3require("./_isArray");
4/**
5 * This checks whether a function has a [methodname] function. If it isn't an
6 * array it will execute that function otherwise it will default to the ramda
7 * implementation.
8 *
9 * @private
10 * @param {Function} fn ramda implemtation
11 * @param {String} methodname property to check for a custom implementation
12 * @return {Object} Whatever the return value of the method is.
13 */
14
15
16function _checkForMethod(methodname, fn) {
17 return function () {
18 var length = arguments.length;
19
20 if (length === 0) {
21 return fn();
22 }
23
24 var obj = arguments[length - 1];
25 return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
26 };
27}
28
29module.exports = _checkForMethod;
\No newline at end of file