diff --git a/lodash.js b/lodash.js index c27638b24..391973540 100644 --- a/lodash.js +++ b/lodash.js @@ -1333,6 +1333,19 @@ : asciiToArray(string); } + /** + * Creates a function that throws an error with `message`. + * + * @private + * @param {stirng} message The error message. + * @returns {Function} Returns the new thrower function. + */ + function thrower(message) { + return function() { + throw new Error(message); + }; + } + /** * Used by `_.unescape` to convert HTML entities to characters. * @@ -1488,13 +1501,14 @@ var nativeCeil = Math.ceil, nativeFloor = Math.floor, nativeGetSymbols = Object.getOwnPropertySymbols, + nativeIsArray = Array.isArray || (Array.isArray = thrower(SHIM_ERROR_TEXT)), nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object.keys, Object), nativeMax = Math.max, nativeMin = Math.min, - nativeNow = Date.now, + nativeNow = Date.now || (Date.now = thrower(SHIM_ERROR_TEXT)), nativeParseInt = context.parseInt, nativeRandom = Math.random, nativeReverse = arrayProto.reverse; @@ -11162,9 +11176,7 @@ * _.isArray(_.noop); * // => false */ - var isArray = Array.isArray || (Array.isArray = function() { - throw new Error(SHIM_ERROR_TEXT); - }); + var isArray = nativeIsArray; /** * Checks if `value` is classified as an `ArrayBuffer` object.