mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-13 12:27:49 +00:00
Add doc blocks for getFuncName and isLaziable. [ci skip]
This commit is contained in:
@@ -3982,6 +3982,37 @@
|
|||||||
return metaMap.get(func);
|
return metaMap.get(func);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of `func`.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Function} func The function to query.
|
||||||
|
* @returns {string} Returns the function name.
|
||||||
|
*/
|
||||||
|
var getFuncName = (function() {
|
||||||
|
if (!support.funcNames) {
|
||||||
|
return constant('');
|
||||||
|
}
|
||||||
|
if (constant.name == 'constant') {
|
||||||
|
return baseProperty('name');
|
||||||
|
}
|
||||||
|
return function(func) {
|
||||||
|
var result = func.name,
|
||||||
|
array = realNames[result],
|
||||||
|
length = array ? array.length : 0;
|
||||||
|
|
||||||
|
while (length--) {
|
||||||
|
var data = array[length],
|
||||||
|
otherFunc = data.func;
|
||||||
|
|
||||||
|
if (otherFunc == null || otherFunc == func) {
|
||||||
|
return data.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
||||||
* customized this function returns the custom method, otherwise it returns
|
* customized this function returns the custom method, otherwise it returns
|
||||||
@@ -4144,30 +4175,13 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var getFuncName = (function() {
|
/**
|
||||||
if (!support.funcNames) {
|
* Checks if `func` has a lazy counterpart.
|
||||||
return constant('');
|
*
|
||||||
}
|
* @private
|
||||||
if (constant.name == 'constant') {
|
* @param {Function} func The function to check.
|
||||||
return baseProperty('name');
|
* @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.
|
||||||
}
|
*/
|
||||||
return function(func) {
|
|
||||||
var result = func.name,
|
|
||||||
array = realNames[result],
|
|
||||||
length = array ? array.length : 0;
|
|
||||||
|
|
||||||
while (length--) {
|
|
||||||
var data = array[length],
|
|
||||||
otherFunc = data.func;
|
|
||||||
|
|
||||||
if (otherFunc == null || otherFunc == func) {
|
|
||||||
return data.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
}());
|
|
||||||
|
|
||||||
function isLaziable(func) {
|
function isLaziable(func) {
|
||||||
var funcName = getFuncName(func);
|
var funcName = getFuncName(func);
|
||||||
return !!funcName && func === lodash[funcName] && funcName in LazyWrapper.prototype;
|
return !!funcName && func === lodash[funcName] && funcName in LazyWrapper.prototype;
|
||||||
|
|||||||
Reference in New Issue
Block a user