mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Add thrower helper.
This commit is contained in:
20
lodash.js
20
lodash.js
@@ -1333,6 +1333,19 @@
|
|||||||
: asciiToArray(string);
|
: 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.
|
* Used by `_.unescape` to convert HTML entities to characters.
|
||||||
*
|
*
|
||||||
@@ -1488,13 +1501,14 @@
|
|||||||
var nativeCeil = Math.ceil,
|
var nativeCeil = Math.ceil,
|
||||||
nativeFloor = Math.floor,
|
nativeFloor = Math.floor,
|
||||||
nativeGetSymbols = Object.getOwnPropertySymbols,
|
nativeGetSymbols = Object.getOwnPropertySymbols,
|
||||||
|
nativeIsArray = Array.isArray || (Array.isArray = thrower(SHIM_ERROR_TEXT)),
|
||||||
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
|
||||||
nativeIsFinite = context.isFinite,
|
nativeIsFinite = context.isFinite,
|
||||||
nativeJoin = arrayProto.join,
|
nativeJoin = arrayProto.join,
|
||||||
nativeKeys = overArg(Object.keys, Object),
|
nativeKeys = overArg(Object.keys, Object),
|
||||||
nativeMax = Math.max,
|
nativeMax = Math.max,
|
||||||
nativeMin = Math.min,
|
nativeMin = Math.min,
|
||||||
nativeNow = Date.now,
|
nativeNow = Date.now || (Date.now = thrower(SHIM_ERROR_TEXT)),
|
||||||
nativeParseInt = context.parseInt,
|
nativeParseInt = context.parseInt,
|
||||||
nativeRandom = Math.random,
|
nativeRandom = Math.random,
|
||||||
nativeReverse = arrayProto.reverse;
|
nativeReverse = arrayProto.reverse;
|
||||||
@@ -11162,9 +11176,7 @@
|
|||||||
* _.isArray(_.noop);
|
* _.isArray(_.noop);
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
var isArray = Array.isArray || (Array.isArray = function() {
|
var isArray = nativeIsArray;
|
||||||
throw new Error(SHIM_ERROR_TEXT);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is classified as an `ArrayBuffer` object.
|
* Checks if `value` is classified as an `ArrayBuffer` object.
|
||||||
|
|||||||
Reference in New Issue
Block a user