mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Simplify getFuncName.
This commit is contained in:
@@ -1046,14 +1046,6 @@
|
|||||||
*/
|
*/
|
||||||
support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype');
|
support.enumPrototypes = propertyIsEnumerable.call(Ctor, 'prototype');
|
||||||
|
|
||||||
/**
|
|
||||||
* Detect if `Function#name` is supported (all but IE).
|
|
||||||
*
|
|
||||||
* @memberOf _.support
|
|
||||||
* @type boolean
|
|
||||||
*/
|
|
||||||
support.funcNames = typeof Function.name == 'string';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9).
|
* Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9).
|
||||||
*
|
*
|
||||||
@@ -4043,29 +4035,20 @@
|
|||||||
* @param {Function} func The function to query.
|
* @param {Function} func The function to query.
|
||||||
* @returns {string} Returns the function name.
|
* @returns {string} Returns the function name.
|
||||||
*/
|
*/
|
||||||
var getFuncName = (function() {
|
function getFuncName(func) {
|
||||||
if (!support.funcNames) {
|
var result = func.name,
|
||||||
return constant('');
|
array = realNames[result],
|
||||||
}
|
length = array ? array.length : 0;
|
||||||
if (constant.name == 'constant') {
|
|
||||||
return baseProperty('name');
|
|
||||||
}
|
|
||||||
return function(func) {
|
|
||||||
var result = func.name,
|
|
||||||
array = realNames[result],
|
|
||||||
length = array ? array.length : 0;
|
|
||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
var data = array[length],
|
var data = array[length],
|
||||||
otherFunc = data.func;
|
otherFunc = data.func;
|
||||||
|
if (otherFunc == null || otherFunc == func) {
|
||||||
if (otherFunc == null || otherFunc == func) {
|
return data.name;
|
||||||
return data.name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
}
|
||||||
};
|
return result;
|
||||||
}());
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
||||||
|
|||||||
Reference in New Issue
Block a user