mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 03:17:49 +00:00
Add an error message to each TypeError.
This commit is contained in:
23
lodash.js
23
lodash.js
@@ -25,6 +25,9 @@
|
|||||||
/** Used as the property name for wrapper metadata */
|
/** Used as the property name for wrapper metadata */
|
||||||
var expando = '__lodash@' + version + '__';
|
var expando = '__lodash@' + version + '__';
|
||||||
|
|
||||||
|
/** Used as the TypeError message for "Functions" methods */
|
||||||
|
var funcErrorText = 'Expected a function';
|
||||||
|
|
||||||
/** Used to generate unique IDs */
|
/** Used to generate unique IDs */
|
||||||
var idCounter = 0;
|
var idCounter = 0;
|
||||||
|
|
||||||
@@ -2074,7 +2077,7 @@
|
|||||||
isPartialRight = bitmask & PARTIAL_RIGHT_FLAG;
|
isPartialRight = bitmask & PARTIAL_RIGHT_FLAG;
|
||||||
|
|
||||||
if (!isBindKey && !isFunction(func)) {
|
if (!isBindKey && !isFunction(func)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
if (isPartial && !partialArgs.length) {
|
if (isPartial && !partialArgs.length) {
|
||||||
bitmask &= ~PARTIAL_FLAG;
|
bitmask &= ~PARTIAL_FLAG;
|
||||||
@@ -4833,7 +4836,7 @@
|
|||||||
*/
|
*/
|
||||||
function after(n, func) {
|
function after(n, func) {
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
n = nativeIsFinite(n = +n) ? n : 0;
|
n = nativeIsFinite(n = +n) ? n : 0;
|
||||||
return function() {
|
return function() {
|
||||||
@@ -4997,7 +5000,7 @@
|
|||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
if (!isFunction(funcs[length])) {
|
if (!isFunction(funcs[length])) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
@@ -5100,7 +5103,7 @@
|
|||||||
trailing = true;
|
trailing = true;
|
||||||
|
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
wait = wait < 0 ? 0 : wait;
|
wait = wait < 0 ? 0 : wait;
|
||||||
if (options === true) {
|
if (options === true) {
|
||||||
@@ -5205,7 +5208,7 @@
|
|||||||
*/
|
*/
|
||||||
function defer(func) {
|
function defer(func) {
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
var args = slice(arguments, 1);
|
var args = slice(arguments, 1);
|
||||||
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
||||||
@@ -5229,7 +5232,7 @@
|
|||||||
*/
|
*/
|
||||||
function delay(func, wait) {
|
function delay(func, wait) {
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
var args = slice(arguments, 2);
|
var args = slice(arguments, 2);
|
||||||
return setTimeout(function() { func.apply(undefined, args); }, wait);
|
return setTimeout(function() { func.apply(undefined, args); }, wait);
|
||||||
@@ -5274,7 +5277,7 @@
|
|||||||
*/
|
*/
|
||||||
function memoize(func, resolver) {
|
function memoize(func, resolver) {
|
||||||
if (!isFunction(func) || (resolver && !isFunction(resolver))) {
|
if (!isFunction(func) || (resolver && !isFunction(resolver))) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
var memoized = function() {
|
var memoized = function() {
|
||||||
var cache = memoized.cache,
|
var cache = memoized.cache,
|
||||||
@@ -5309,7 +5312,7 @@
|
|||||||
*/
|
*/
|
||||||
function negate(predicate) {
|
function negate(predicate) {
|
||||||
if (!isFunction(predicate)) {
|
if (!isFunction(predicate)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
return !predicate.apply(this, arguments);
|
return !predicate.apply(this, arguments);
|
||||||
@@ -5338,7 +5341,7 @@
|
|||||||
result;
|
result;
|
||||||
|
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
if (ran) {
|
if (ran) {
|
||||||
@@ -5460,7 +5463,7 @@
|
|||||||
trailing = true;
|
trailing = true;
|
||||||
|
|
||||||
if (!isFunction(func)) {
|
if (!isFunction(func)) {
|
||||||
throw new TypeError;
|
throw new TypeError(funcErrorText);
|
||||||
}
|
}
|
||||||
if (options === false) {
|
if (options === false) {
|
||||||
leading = false;
|
leading = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user