Simplify getFuncName.

This commit is contained in:
jdalton
2015-05-15 20:21:39 -07:00
parent 3490f8acb5
commit d6937baa8e

View File

@@ -1046,14 +1046,6 @@
*/
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).
*
@@ -4043,29 +4035,20 @@
* @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;
function getFuncName(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;
}
while (length--) {
var data = array[length],
otherFunc = data.func;
if (otherFunc == null || otherFunc == func) {
return data.name;
}
return result;
};
}());
}
return result;
}
/**
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is