From d6937baa8e8d93675f5b54765c3f3327e72c6688 Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 15 May 2015 20:21:39 -0700 Subject: [PATCH] Simplify `getFuncName`. --- lodash.src.js | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index c970ceda6..c2fee8767 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -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