diff --git a/lodash.src.js b/lodash.src.js index be65b2cd9..d94f1772c 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -331,6 +331,20 @@ return -1; } + /** + * The base implementation of `_.isFunction` without support for environments + * with incorrect `typeof` results. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + */ + function baseIsFunction(value) { + // Avoid a Chakra JIT bug in compatibility modes of IE 11. + // See https://github.com/jashkenas/underscore/issues/1621 for more details. + return typeof value == 'function' || false; + } + /** * The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer` * to define the sort order of `array` and replaces criteria objects with their @@ -7502,7 +7516,7 @@ if (!length) { return function() { return arguments[0]; }; } - if (!arrayEvery(funcs, isFunction)) { + if (!arrayEvery(funcs, baseIsFunction)) { throw new TypeError(FUNC_ERROR_TEXT); } return function() { @@ -7547,7 +7561,7 @@ if (fromIndex < 0) { return function() { return arguments[0]; }; } - if (!arrayEvery(funcs, isFunction)) { + if (!arrayEvery(funcs, baseIsFunction)) { throw new TypeError(FUNC_ERROR_TEXT); } return function() { @@ -8297,20 +8311,12 @@ * _.isFunction(/abc/); * // => false */ - function isFunction(value) { - // Avoid a Chakra JIT bug in compatibility modes of IE 11. - // See https://github.com/jashkenas/underscore/issues/1621 for more details. - return typeof value == 'function' || false; - } - // Fallback for environments that return incorrect `typeof` operator results. - if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) { - isFunction = function(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in older versions of Chrome and Safari which return 'function' for regexes - // and Safari 8 equivalents which return 'object' for typed array constructors. - return objToString.call(value) == funcTag; - }; - } + var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 equivalents which return 'object' for typed array constructors. + return objToString.call(value) == funcTag; + }; /** * Checks if `value` is the language type of `Object`.