mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Add thrower helper.
This commit is contained in:
20
lodash.js
20
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.
|
||||
|
||||
Reference in New Issue
Block a user