diff --git a/_baseDelay.js b/_baseDelay.js index ca675ef9d..4c39c234b 100644 --- a/_baseDelay.js +++ b/_baseDelay.js @@ -1,6 +1,3 @@ -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * The base implementation of `delay` and `defer` which accepts `args` * to provide to `func`. @@ -13,7 +10,7 @@ const FUNC_ERROR_TEXT = 'Expected a function'; */ function baseDelay(func, wait, args) { if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } return setTimeout(() => func(...args), wait); } diff --git a/_createFlow.js b/_createFlow.js index fb84beceb..f371de724 100644 --- a/_createFlow.js +++ b/_createFlow.js @@ -1,6 +1,3 @@ -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * Creates a `flow` or `flowRight` function. * @@ -22,7 +19,7 @@ function createFlow(fromRight) { while (index--) { func = funcs[index]; if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } } return function(...args) { diff --git a/_createWrap.js b/_createWrap.js index e9bef444f..87d3e8312 100644 --- a/_createWrap.js +++ b/_createWrap.js @@ -9,9 +9,6 @@ import setData from './_setData.js'; import setWrapToString from './_setWrapToString.js'; import toInteger from './toInteger.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** Used to compose bitmasks for function metadata. */ const WRAP_BIND_FLAG = 1; const WRAP_BIND_KEY_FLAG = 2; @@ -51,7 +48,7 @@ const nativeMax = Math.max; function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { const isBindKey = bitmask & WRAP_BIND_KEY_FLAG; if (!isBindKey && typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } let length = partials ? partials.length : 0; if (!length) { diff --git a/after.js b/after.js index 01a312f22..e450431b4 100644 --- a/after.js +++ b/after.js @@ -1,8 +1,5 @@ import toInteger from './toInteger.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * The opposite of `before`; this method creates a function that invokes * `func` once it's called `n` or more times. @@ -28,7 +25,7 @@ const FUNC_ERROR_TEXT = 'Expected a function'; */ function after(n, func) { if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } n = toInteger(n); return function(...args) { diff --git a/before.js b/before.js index 8bdb0e797..c80486e4a 100644 --- a/before.js +++ b/before.js @@ -1,8 +1,5 @@ import toInteger from './toInteger.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * Creates a function that invokes `func`, with the `this` binding and arguments * of the created function, while it's called less than `n` times. Subsequent @@ -22,7 +19,7 @@ const FUNC_ERROR_TEXT = 'Expected a function'; function before(n, func) { let result; if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } n = toInteger(n); return function(...args) { diff --git a/cond.js b/cond.js index 03545f077..d9fbe478c 100644 --- a/cond.js +++ b/cond.js @@ -1,9 +1,6 @@ import apply from './_apply.js'; import arrayMap from './_arrayMap.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * Creates a function that iterates over `pairs` and invokes the corresponding * function of the first predicate to return truthy. The predicate-function @@ -37,7 +34,7 @@ function cond(pairs) { pairs = !length ? [] : arrayMap(pairs, pair => { if (typeof pair[1] != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } return [pair[0], pair[1]]; }); diff --git a/debounce.js b/debounce.js index de04442de..407341925 100644 --- a/debounce.js +++ b/debounce.js @@ -1,9 +1,6 @@ import isObject from './isObject.js'; import toNumber from './toNumber.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /* Built-in method references for those with the same name as other `lodash` methods. */ const nativeMax = Math.max; const nativeMin = Math.min; @@ -75,7 +72,7 @@ function debounce(func, wait, options) { let trailing = true; if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } wait = toNumber(wait) || 0; if (isObject(options)) { diff --git a/memoize.js b/memoize.js index cc11dbc19..6a0aa4c4d 100644 --- a/memoize.js +++ b/memoize.js @@ -1,8 +1,5 @@ import MapCache from './_MapCache.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * Creates a function that memoizes the result of `func`. If `resolver` is * provided, it determines the cache key for storing the result based on the @@ -48,7 +45,7 @@ const FUNC_ERROR_TEXT = 'Expected a function'; */ function memoize(func, resolver) { if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } const memoized = function(...args) { const key = resolver ? resolver.apply(this, args) : args[0]; diff --git a/negate.js b/negate.js index 2f72e99a9..617bf8a38 100644 --- a/negate.js +++ b/negate.js @@ -1,6 +1,3 @@ -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * Creates a function that negates the result of the predicate `func`. The * `func` predicate is invoked with the `this` binding and arguments of the @@ -22,7 +19,7 @@ const FUNC_ERROR_TEXT = 'Expected a function'; */ function negate(predicate) { if (typeof predicate != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } return function(...args) { return !predicate.apply(this, args); diff --git a/spread.js b/spread.js index bf0564df2..4add759f7 100644 --- a/spread.js +++ b/spread.js @@ -3,9 +3,6 @@ import arrayPush from './_arrayPush.js'; import castSlice from './_castSlice.js'; import toInteger from './toInteger.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /* Built-in method references for those with the same name as other `lodash` methods. */ const nativeMax = Math.max; @@ -44,7 +41,7 @@ const nativeMax = Math.max; */ function spread(func, start) { if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } start = start == null ? 0 : nativeMax(toInteger(start), 0); return (...args) => { diff --git a/throttle.js b/throttle.js index a3410a37e..abdee7ca3 100644 --- a/throttle.js +++ b/throttle.js @@ -1,9 +1,6 @@ import debounce from './debounce.js'; import isObject from './isObject.js'; -/** Error message constants. */ -const FUNC_ERROR_TEXT = 'Expected a function'; - /** * Creates a throttled function that only invokes `func` at most once per * every `wait` milliseconds. The throttled function comes with a `cancel` @@ -52,7 +49,7 @@ function throttle(func, wait, options) { let trailing = true; if (typeof func != 'function') { - throw new TypeError(FUNC_ERROR_TEXT); + throw new TypeError('Expected a function'); } if (isObject(options)) { leading = 'leading' in options ? !!options.leading : leading;