source: node_modules/ramda/es/internal/_checkForMethod.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: 810 bytes
RevLine 
[d24f17c]1import _isArray from "./_isArray.js";
2/**
3 * This checks whether a function has a [methodname] function. If it isn't an
4 * array it will execute that function otherwise it will default to the ramda
5 * implementation.
6 *
7 * @private
8 * @param {Function} fn ramda implementation
9 * @param {String} methodname property to check for a custom implementation
10 * @return {Object} Whatever the return value of the method is.
11 */
12
13export default function _checkForMethod(methodname, fn) {
14 return function () {
15 var length = arguments.length;
16
17 if (length === 0) {
18 return fn();
19 }
20
21 var obj = arguments[length - 1];
22 return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
23 };
24}
Note: See TracBrowser for help on using the repository browser.