diff --git a/_baseDifference.js b/_baseDifference.js index 0fe5d64c2..be119496a 100644 --- a/_baseDifference.js +++ b/_baseDifference.js @@ -2,7 +2,6 @@ import SetCache from './_SetCache.js'; import arrayIncludes from './_arrayIncludes.js'; import arrayIncludesWith from './_arrayIncludesWith.js'; import arrayMap from './_arrayMap.js'; -import baseUnary from './_baseUnary.js'; import cacheHas from './_cacheHas.js'; /** Used as the size to enable large array optimizations. */ @@ -31,7 +30,7 @@ function baseDifference(array, values, iteratee, comparator) { return result; } if (iteratee) { - values = arrayMap(values, baseUnary(iteratee)); + values = arrayMap(values, value => iteratee(value)); } if (comparator) { includes = arrayIncludesWith; diff --git a/_baseIntersection.js b/_baseIntersection.js index ef55ef34f..7935b4d99 100644 --- a/_baseIntersection.js +++ b/_baseIntersection.js @@ -2,7 +2,6 @@ import SetCache from './_SetCache.js'; import arrayIncludes from './_arrayIncludes.js'; import arrayIncludesWith from './_arrayIncludesWith.js'; import arrayMap from './_arrayMap.js'; -import baseUnary from './_baseUnary.js'; import cacheHas from './_cacheHas.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -32,7 +31,7 @@ function baseIntersection(arrays, iteratee, comparator) { while (othIndex--) { array = arrays[othIndex]; if (othIndex && iteratee) { - array = arrayMap(array, baseUnary(iteratee)); + array = arrayMap(array, valye => iteratee(value)); } maxLength = nativeMin(array.length, maxLength); caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) diff --git a/_baseOrderBy.js b/_baseOrderBy.js index 641599472..147612a82 100644 --- a/_baseOrderBy.js +++ b/_baseOrderBy.js @@ -2,7 +2,6 @@ import arrayMap from './_arrayMap.js'; import baseIteratee from './_baseIteratee.js'; import baseMap from './_baseMap.js'; import baseSortBy from './_baseSortBy.js'; -import baseUnary from './_baseUnary.js'; import compareMultiple from './_compareMultiple.js'; import identity from './identity.js'; @@ -17,7 +16,7 @@ import identity from './identity.js'; */ function baseOrderBy(collection, iteratees, orders) { let index = -1; - iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee)); + iteratees = arrayMap(iteratees.length ? iteratees : [identity], value => baseIteratee(value)); const result = baseMap(collection, (value, key, collection) => { const criteria = arrayMap(iteratees, iteratee => iteratee(value)); diff --git a/_basePullAll.js b/_basePullAll.js index e292b2fa9..19784a9c1 100644 --- a/_basePullAll.js +++ b/_basePullAll.js @@ -1,7 +1,6 @@ import arrayMap from './_arrayMap.js'; import baseIndexOf from './_baseIndexOf.js'; import baseIndexOfWith from './_baseIndexOfWith.js'; -import baseUnary from './_baseUnary.js'; import copyArray from './_copyArray.js'; /** Used for built-in method references. */ @@ -32,7 +31,7 @@ function basePullAll(array, values, iteratee, comparator) { values = copyArray(values); } if (iteratee) { - seen = arrayMap(array, baseUnary(iteratee)); + seen = arrayMap(array, value => iteratee(value)); } while (++index < length) { let fromIndex = 0; diff --git a/_baseUnary.js b/_baseUnary.js deleted file mode 100644 index 039390289..000000000 --- a/_baseUnary.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * The base implementation of `_.unary` without support for storing metadata. - * - * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - */ -function baseUnary(func) { - return value => func(value); -} - -export default baseUnary; diff --git a/_createOver.js b/_createOver.js index 1e60bea8e..ae55b3a0b 100644 --- a/_createOver.js +++ b/_createOver.js @@ -1,7 +1,6 @@ import apply from './_apply.js'; import arrayMap from './_arrayMap.js'; import baseIteratee from './_baseIteratee.js'; -import baseUnary from './_baseUnary.js'; /** * Creates a function like `_.over`. @@ -12,7 +11,7 @@ import baseUnary from './_baseUnary.js'; */ function createOver(arrayFunc) { return (...iteratees) => { - iteratees = arrayMap(iteratees, baseUnary(baseIteratee)); + iteratees = arrayMap(iteratees, iteratee => baseIteratee(iteratee)); return (...args) => { const thisArg = this; return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args)); diff --git a/isArrayBuffer.js b/isArrayBuffer.js index 7a9b46772..93887450d 100644 --- a/isArrayBuffer.js +++ b/isArrayBuffer.js @@ -1,5 +1,4 @@ import baseIsArrayBuffer from './_baseIsArrayBuffer.js'; -import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ @@ -22,6 +21,8 @@ const nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer; * _.isArrayBuffer(new Array(2)); * // => false */ -const isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; +const isArrayBuffer = nodeIsArrayBuffer + ? value => nodeIsArrayBuffer(value) + : baseIsArrayBuffer; export default isArrayBuffer; diff --git a/isDate.js b/isDate.js index 3fffa3f16..4c28e1254 100644 --- a/isDate.js +++ b/isDate.js @@ -1,5 +1,4 @@ import baseIsDate from './_baseIsDate.js'; -import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ @@ -22,6 +21,8 @@ const nodeIsDate = nodeUtil && nodeUtil.isDate; * _.isDate('Mon April 23 2012'); * // => false */ -const isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; +const isDate = nodeIsDate + ? value => nodeIsDate(value) + : baseIsDate; export default isDate; diff --git a/isMap.js b/isMap.js index 277bc7bb9..d1192ffd6 100644 --- a/isMap.js +++ b/isMap.js @@ -1,5 +1,4 @@ import baseIsMap from './_baseIsMap.js'; -import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ @@ -22,6 +21,8 @@ const nodeIsMap = nodeUtil && nodeUtil.isMap; * _.isMap(new WeakMap); * // => false */ -const isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; +const isMap = nodeIsMap + ? value => nodeIsMap(value) + : baseIsMap; export default isMap; diff --git a/isRegExp.js b/isRegExp.js index 7282f1e7c..d4b9aba2d 100644 --- a/isRegExp.js +++ b/isRegExp.js @@ -1,5 +1,4 @@ import baseIsRegExp from './_baseIsRegExp.js'; -import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ @@ -22,6 +21,8 @@ const nodeIsRegExp = nodeUtil && nodeUtil.isRegExp; * _.isRegExp('/abc/'); * // => false */ -const isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; +const isRegExp = nodeIsRegExp + ? value => nodeIsRegExp(value) + : baseIsRegExp; export default isRegExp; diff --git a/isSet.js b/isSet.js index 56475bd41..83ed191a5 100644 --- a/isSet.js +++ b/isSet.js @@ -1,5 +1,4 @@ import baseIsSet from './_baseIsSet.js'; -import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ @@ -22,6 +21,8 @@ const nodeIsSet = nodeUtil && nodeUtil.isSet; * _.isSet(new WeakSet); * // => false */ -const isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; +const isSet = nodeIsSet + ? value => nodeIsSet(value) + : baseIsSet; export default isSet; diff --git a/isTypedArray.js b/isTypedArray.js index 1dd4830a5..95e3166be 100644 --- a/isTypedArray.js +++ b/isTypedArray.js @@ -1,5 +1,4 @@ import baseIsTypedArray from './_baseIsTypedArray.js'; -import baseUnary from './_baseUnary.js'; import nodeUtil from './_nodeUtil.js'; /* Node.js helper references. */ @@ -22,6 +21,8 @@ const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; * _.isTypedArray([]); * // => false */ -const isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; +const isTypedArray = nodeIsTypedArray + ? value => nodeIsTypedArray(value) + : baseIsTypedArray; export default isTypedArray; diff --git a/overArgs.js b/overArgs.js index 7e7bc5243..187c9e11b 100644 --- a/overArgs.js +++ b/overArgs.js @@ -2,8 +2,6 @@ import apply from './_apply.js'; import arrayMap from './_arrayMap.js'; import baseFlatten from './_baseFlatten.js'; import baseIteratee from './_baseIteratee.js'; -import baseUnary from './_baseUnary.js'; -import isArray from './isArray.js'; /* Built-in method references for those with the same name as other `lodash` methods. */ const nativeMin = Math.min; @@ -40,10 +38,7 @@ const nativeMin = Math.min; * // => [100, 10] */ function overArgs(func, ...transforms) { - transforms = (transforms.length == 1 && isArray(transforms[0])) - ? arrayMap(transforms[0], baseUnary(baseIteratee)) - : arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee)); - + transforms = arrayMap(transforms, transform => baseIteratee(transform)); const funcsLength = transforms.length; return function(...args) { let index = -1; diff --git a/unary.js b/unary.js deleted file mode 100644 index cdb59ffb5..000000000 --- a/unary.js +++ /dev/null @@ -1,22 +0,0 @@ -import ary from './ary.js'; - -/** - * Creates a function that accepts up to one argument, ignoring any - * additional arguments. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Function - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. - * @example - * - * _.map(['6', '8', '10'], _.unary(parseInt)); - * // => [6, 8, 10] - */ -function unary(func) { - return ary(func, 1); -} - -export default unary; diff --git a/without.js b/without.js index 21ca42f8a..f1613b3bd 100644 --- a/without.js +++ b/without.js @@ -21,7 +21,8 @@ import isArrayLikeObject from './isArrayLikeObject.js'; * _.without([2, 1, 2, 3], 1, 2); * // => [3] */ -const without = (array, ...values) => - isArrayLikeObject(array) ? baseDifference(array, values) : []; +function without(array, ...values) { + return isArrayLikeObject(array) ? baseDifference(array, values) : []; +} export default without;