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:
848 bytes
|
Line | |
---|
1 | var _isArray =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./_isArray.js");
|
---|
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 implementation
|
---|
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 |
|
---|
16 | function _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 |
|
---|
29 | module.exports = _checkForMethod; |
---|
Note:
See
TracBrowser
for help on using the repository browser.