From 7167d7e09ffe9f6bc58788a1440b72b3974d0a6e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 6 Jan 2017 15:41:39 -0800 Subject: [PATCH] Apply arrow function transform. --- _arrayLikeKeys.js | 7 ++--- _baseClone.js | 2 +- _baseInverter.js | 2 +- _baseMatches.js | 4 +-- _baseMatchesProperty.js | 2 +- _baseOrderBy.js | 10 ++---- _basePick.js | 4 +-- _baseProperty.js | 4 +-- _basePropertyDeep.js | 4 +-- _basePropertyOf.js | 4 +-- _baseReduce.js | 2 +- _baseSetData.js | 2 +- _baseSetToString.js | 14 ++++----- _baseSome.js | 2 +- _baseToPairs.js | 4 +-- _baseUnary.js | 4 +-- _baseValues.js | 4 +-- _baseWrapperValue.js | 4 +-- _createAggregator.js | 2 +- _createAssigner.js | 2 +- _createBaseEach.js | 2 +- _createBaseFor.js | 2 +- _createCaseFirst.js | 2 +- _createCompounder.js | 4 +-- _createFind.js | 4 +-- _createFlow.js | 2 +- _createInverter.js | 4 +-- _createMathOperation.js | 2 +- _createOver.js | 6 ++-- _createRange.js | 2 +- _createRelationalOperation.js | 2 +- _createRound.js | 2 +- _createSet.js | 4 +-- _createToPairs.js | 2 +- _defineProperty.js | 4 +-- _equalArrays.js | 2 +- _getData.js | 4 +-- _getSymbols.js | 6 ++-- _getSymbolsIn.js | 2 +- _getTag.js | 2 +- _isMasked.js | 4 +-- _mapToArray.js | 2 +- _matchesStrictComparable.js | 2 +- _memoizeCapped.js | 2 +- _nodeUtil.js | 4 +-- _overArg.js | 4 +-- _setToArray.js | 2 +- _stringToPath.js | 4 +-- _updateWrapDetails.js | 2 +- add.js | 4 +-- assignIn.js | 2 +- assignInWith.js | 2 +- assignWith.js | 2 +- attempt.js | 2 +- bind.js | 2 +- bindAll.js | 4 +-- bindKey.js | 2 +- camelCase.js | 2 +- cond.js | 2 +- constant.js | 4 +-- countBy.js | 2 +- defaults.js | 2 +- defaultsDeep.js | 2 +- defer.js | 4 +-- delay.js | 4 +-- difference.js | 8 ++--- differenceBy.js | 2 +- differenceWith.js | 2 +- divide.js | 4 +-- groupBy.js | 2 +- gte.js | 4 +-- intersection.js | 2 +- intersectionBy.js | 2 +- intersectionWith.js | 2 +- invert.js | 2 +- invertBy.js | 2 +- invokeMap.js | 4 +-- isArguments.js | 6 ++-- kebabCase.js | 4 +-- keyBy.js | 2 +- lodash.default.js | 58 ++++++++++++++++------------------- lowerCase.js | 4 +-- lte.js | 4 +-- mapKeys.js | 2 +- mapValues.js | 2 +- merge.js | 2 +- mergeWith.js | 2 +- method.js | 6 +--- methodOf.js | 6 +--- multiply.js | 4 +-- now.js | 4 +-- nthArg.js | 4 +-- overArgs.js | 2 +- pick.js | 4 +-- pickBy.js | 8 ++--- propertyOf.js | 4 +-- pullAt.js | 6 ++-- rearg.js | 4 +-- snakeCase.js | 6 ++-- startCase.js | 4 +-- subtract.js | 4 +-- template.js | 15 ++++++--- transform.js | 4 +-- unionWith.js | 2 +- unzip.js | 6 ++-- unzipWith.js | 4 +-- upperCase.js | 6 ++-- xorWith.js | 7 ++--- 108 files changed, 172 insertions(+), 271 deletions(-) diff --git a/_arrayLikeKeys.js b/_arrayLikeKeys.js index de5d55155..c2161ea4b 100644 --- a/_arrayLikeKeys.js +++ b/_arrayLikeKeys.js @@ -32,13 +32,12 @@ function arrayLikeKeys(value, inherited) { if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && ( // Safari 9 has enumerable `arguments.length` in strict mode. - key == 'length' || + (key == 'length' || // Node.js 0.10 has enumerable non-index properties on buffers. (isBuff && (key == 'offset' || key == 'parent')) || // PhantomJS 2 has enumerable non-index properties on typed arrays. - (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || - // Skip index properties. - isIndex(key, length) + (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || // Skip index properties. + isIndex(key, length)) ))) { result.push(key); } diff --git a/_baseClone.js b/_baseClone.js index 324cce92c..d2ca075b0 100644 --- a/_baseClone.js +++ b/_baseClone.js @@ -139,7 +139,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) { : (isFlat ? keysIn : keys); var props = isArr ? undefined : keysFunc(value); - arrayEach(props || value, function(subValue, key) { + arrayEach(props || value, (subValue, key) => { if (props) { key = subValue; subValue = value[key]; diff --git a/_baseInverter.js b/_baseInverter.js index 5cb3800ce..f42aa7ce1 100644 --- a/_baseInverter.js +++ b/_baseInverter.js @@ -12,7 +12,7 @@ import baseForOwn from './_baseForOwn.js'; * @returns {Function} Returns `accumulator`. */ function baseInverter(object, setter, iteratee, accumulator) { - baseForOwn(object, function(value, key, object) { + baseForOwn(object, (value, key, object) => { setter(accumulator, iteratee(value), key, object); }); return accumulator; diff --git a/_baseMatches.js b/_baseMatches.js index 74e9971f6..a8b556fed 100644 --- a/_baseMatches.js +++ b/_baseMatches.js @@ -14,9 +14,7 @@ function baseMatches(source) { if (matchData.length == 1 && matchData[0][2]) { return matchesStrictComparable(matchData[0][0], matchData[0][1]); } - return function(object) { - return object === source || baseIsMatch(object, source, matchData); - }; + return object => object === source || baseIsMatch(object, source, matchData); } export default baseMatches; diff --git a/_baseMatchesProperty.js b/_baseMatchesProperty.js index f92d68087..6370abd5a 100644 --- a/_baseMatchesProperty.js +++ b/_baseMatchesProperty.js @@ -22,7 +22,7 @@ function baseMatchesProperty(path, srcValue) { if (isKey(path) && isStrictComparable(srcValue)) { return matchesStrictComparable(toKey(path), srcValue); } - return function(object) { + return object => { var objValue = get(object, path); return (objValue === undefined && objValue === srcValue) ? hasIn(object, path) diff --git a/_baseOrderBy.js b/_baseOrderBy.js index b9d00aaf9..bc8a47e64 100644 --- a/_baseOrderBy.js +++ b/_baseOrderBy.js @@ -19,16 +19,12 @@ function baseOrderBy(collection, iteratees, orders) { var index = -1; iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee)); - var result = baseMap(collection, function(value, key, collection) { - var criteria = arrayMap(iteratees, function(iteratee) { - return iteratee(value); - }); + var result = baseMap(collection, (value, key, collection) => { + var criteria = arrayMap(iteratees, iteratee => iteratee(value)); return { 'criteria': criteria, 'index': ++index, 'value': value }; }); - return baseSortBy(result, function(object, other) { - return compareMultiple(object, other, orders); - }); + return baseSortBy(result, (object, other) => compareMultiple(object, other, orders)); } export default baseOrderBy; diff --git a/_basePick.js b/_basePick.js index bf80ff0f4..ac5198963 100644 --- a/_basePick.js +++ b/_basePick.js @@ -11,9 +11,7 @@ import hasIn from './hasIn.js'; * @returns {Object} Returns the new object. */ function basePick(object, paths) { - return basePickBy(object, paths, function(value, path) { - return hasIn(object, path); - }); + return basePickBy(object, paths, (value, path) => hasIn(object, path)); } export default basePick; diff --git a/_baseProperty.js b/_baseProperty.js index 90f032924..a4d2efa35 100644 --- a/_baseProperty.js +++ b/_baseProperty.js @@ -6,9 +6,7 @@ * @returns {Function} Returns the new accessor function. */ function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; + return object => object == null ? undefined : object[key]; } export default baseProperty; diff --git a/_basePropertyDeep.js b/_basePropertyDeep.js index 2f779ab74..7ac332e2f 100644 --- a/_basePropertyDeep.js +++ b/_basePropertyDeep.js @@ -8,9 +8,7 @@ import baseGet from './_baseGet.js'; * @returns {Function} Returns the new accessor function. */ function basePropertyDeep(path) { - return function(object) { - return baseGet(object, path); - }; + return object => baseGet(object, path); } export default basePropertyDeep; diff --git a/_basePropertyOf.js b/_basePropertyOf.js index e0ec2b860..a0ab3a5e3 100644 --- a/_basePropertyOf.js +++ b/_basePropertyOf.js @@ -6,9 +6,7 @@ * @returns {Function} Returns the new accessor function. */ function basePropertyOf(object) { - return function(key) { - return object == null ? undefined : object[key]; - }; + return key => object == null ? undefined : object[key]; } export default basePropertyOf; diff --git a/_baseReduce.js b/_baseReduce.js index 069fed50f..e836d73a4 100644 --- a/_baseReduce.js +++ b/_baseReduce.js @@ -12,7 +12,7 @@ * @returns {*} Returns the accumulated value. */ function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { - eachFunc(collection, function(value, index, collection) { + eachFunc(collection, (value, index, collection) => { accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection); diff --git a/_baseSetData.js b/_baseSetData.js index 8d57b0b39..f901afef2 100644 --- a/_baseSetData.js +++ b/_baseSetData.js @@ -9,7 +9,7 @@ import metaMap from './_metaMap.js'; * @param {*} data The metadata. * @returns {Function} Returns `func`. */ -var baseSetData = !metaMap ? identity : function(func, data) { +var baseSetData = !metaMap ? identity : (func, data) => { metaMap.set(func, data); return func; }; diff --git a/_baseSetToString.js b/_baseSetToString.js index e712c11a0..2a00fceff 100644 --- a/_baseSetToString.js +++ b/_baseSetToString.js @@ -10,13 +10,11 @@ import identity from './identity.js'; * @param {Function} string The `toString` result. * @returns {Function} Returns `func`. */ -var baseSetToString = !defineProperty ? identity : function(func, string) { - return defineProperty(func, 'toString', { - 'configurable': true, - 'enumerable': false, - 'value': constant(string), - 'writable': true - }); -}; +var baseSetToString = !defineProperty ? identity : (func, string) => defineProperty(func, 'toString', { + 'configurable': true, + 'enumerable': false, + 'value': constant(string), + 'writable': true +}); export default baseSetToString; diff --git a/_baseSome.js b/_baseSome.js index f2647c23c..aec0ff733 100644 --- a/_baseSome.js +++ b/_baseSome.js @@ -12,7 +12,7 @@ import baseEach from './_baseEach.js'; function baseSome(collection, predicate) { var result; - baseEach(collection, function(value, index, collection) { + baseEach(collection, (value, index, collection) => { result = predicate(value, index, collection); return !result; }); diff --git a/_baseToPairs.js b/_baseToPairs.js index c1e3f9f8c..c4609ca13 100644 --- a/_baseToPairs.js +++ b/_baseToPairs.js @@ -10,9 +10,7 @@ import arrayMap from './_arrayMap.js'; * @returns {Object} Returns the key-value pairs. */ function baseToPairs(object, props) { - return arrayMap(props, function(key) { - return [key, object[key]]; - }); + return arrayMap(props, key => [key, object[key]]); } export default baseToPairs; diff --git a/_baseUnary.js b/_baseUnary.js index e756a3222..039390289 100644 --- a/_baseUnary.js +++ b/_baseUnary.js @@ -6,9 +6,7 @@ * @returns {Function} Returns the new capped function. */ function baseUnary(func) { - return function(value) { - return func(value); - }; + return value => func(value); } export default baseUnary; diff --git a/_baseValues.js b/_baseValues.js index f3a38d2df..5f20bbf55 100644 --- a/_baseValues.js +++ b/_baseValues.js @@ -11,9 +11,7 @@ import arrayMap from './_arrayMap.js'; * @returns {Object} Returns the array of property values. */ function baseValues(object, props) { - return arrayMap(props, function(key) { - return object[key]; - }); + return arrayMap(props, key => object[key]); } export default baseValues; diff --git a/_baseWrapperValue.js b/_baseWrapperValue.js index 0b6807ee0..c9d1b2bad 100644 --- a/_baseWrapperValue.js +++ b/_baseWrapperValue.js @@ -17,9 +17,7 @@ function baseWrapperValue(value, actions) { if (result instanceof LazyWrapper) { result = result.value(); } - return arrayReduce(actions, function(result, action) { - return action.func.apply(action.thisArg, arrayPush([result], action.args)); - }, result); + return arrayReduce(actions, (result, action) => action.func.apply(action.thisArg, arrayPush([result], action.args)), result); } export default baseWrapperValue; diff --git a/_createAggregator.js b/_createAggregator.js index 578c0ae7b..b8fd331ef 100644 --- a/_createAggregator.js +++ b/_createAggregator.js @@ -12,7 +12,7 @@ import isArray from './isArray.js'; * @returns {Function} Returns the new aggregator function. */ function createAggregator(setter, initializer) { - return function(collection, iteratee) { + return (collection, iteratee) => { var func = isArray(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {}; diff --git a/_createAssigner.js b/_createAssigner.js index 67dc499b5..a83e30f0f 100644 --- a/_createAssigner.js +++ b/_createAssigner.js @@ -9,7 +9,7 @@ import isIterateeCall from './_isIterateeCall.js'; * @returns {Function} Returns the new assigner function. */ function createAssigner(assigner) { - return baseRest(function(object, sources) { + return baseRest((object, sources) => { var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, diff --git a/_createBaseEach.js b/_createBaseEach.js index 2c3181bac..94f6fa28a 100644 --- a/_createBaseEach.js +++ b/_createBaseEach.js @@ -9,7 +9,7 @@ import isArrayLike from './isArrayLike.js'; * @returns {Function} Returns the new base function. */ function createBaseEach(eachFunc, fromRight) { - return function(collection, iteratee) { + return (collection, iteratee) => { if (collection == null) { return collection; } diff --git a/_createBaseFor.js b/_createBaseFor.js index ac15c59af..483be373b 100644 --- a/_createBaseFor.js +++ b/_createBaseFor.js @@ -6,7 +6,7 @@ * @returns {Function} Returns the new base function. */ function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { + return (object, iteratee, keysFunc) => { var index = -1, iterable = Object(object), props = keysFunc(object), diff --git a/_createCaseFirst.js b/_createCaseFirst.js index 333c7c4c0..83847c576 100644 --- a/_createCaseFirst.js +++ b/_createCaseFirst.js @@ -11,7 +11,7 @@ import toString from './toString.js'; * @returns {Function} Returns the new case function. */ function createCaseFirst(methodName) { - return function(string) { + return string => { string = toString(string); var strSymbols = hasUnicode(string) diff --git a/_createCompounder.js b/_createCompounder.js index f3503fb01..a64ce89e4 100644 --- a/_createCompounder.js +++ b/_createCompounder.js @@ -16,9 +16,7 @@ var reApos = RegExp(rsApos, 'g'); * @returns {Function} Returns the new compounder function. */ function createCompounder(callback) { - return function(string) { - return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); - }; + return string => arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); } export default createCompounder; diff --git a/_createFind.js b/_createFind.js index d3f8bd55f..a6f6c2169 100644 --- a/_createFind.js +++ b/_createFind.js @@ -10,12 +10,12 @@ import keys from './keys.js'; * @returns {Function} Returns the new find function. */ function createFind(findIndexFunc) { - return function(collection, predicate, fromIndex) { + return (collection, predicate, fromIndex) => { var iterable = Object(collection); if (!isArrayLike(collection)) { var iteratee = baseIteratee(predicate, 3); collection = keys(collection); - predicate = function(key) { return iteratee(iterable[key], key, iterable); }; + predicate = key => iteratee(iterable[key], key, iterable); } var index = findIndexFunc(collection, predicate, fromIndex); return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; diff --git a/_createFlow.js b/_createFlow.js index 8e9708469..3c33e8e3a 100644 --- a/_createFlow.js +++ b/_createFlow.js @@ -22,7 +22,7 @@ var WRAP_CURRY_FLAG = 8, * @returns {Function} Returns the new flow function. */ function createFlow(fromRight) { - return flatRest(function(funcs) { + return flatRest(funcs => { var length = funcs.length, index = length, prereq = LodashWrapper.prototype.thru; diff --git a/_createInverter.js b/_createInverter.js index 3db3f12df..939c43a16 100644 --- a/_createInverter.js +++ b/_createInverter.js @@ -9,9 +9,7 @@ import baseInverter from './_baseInverter.js'; * @returns {Function} Returns the new inverter function. */ function createInverter(setter, toIteratee) { - return function(object, iteratee) { - return baseInverter(object, setter, toIteratee(iteratee), {}); - }; + return (object, iteratee) => baseInverter(object, setter, toIteratee(iteratee), {}); } export default createInverter; diff --git a/_createMathOperation.js b/_createMathOperation.js index cffe75d85..fd26eb2e2 100644 --- a/_createMathOperation.js +++ b/_createMathOperation.js @@ -10,7 +10,7 @@ import baseToString from './_baseToString.js'; * @returns {Function} Returns the new mathematical operation function. */ function createMathOperation(operator, defaultValue) { - return function(value, other) { + return (value, other) => { var result; if (value === undefined && other === undefined) { return defaultValue; diff --git a/_createOver.js b/_createOver.js index a79f37385..68d67cc3f 100644 --- a/_createOver.js +++ b/_createOver.js @@ -13,13 +13,11 @@ import flatRest from './_flatRest.js'; * @returns {Function} Returns the new over function. */ function createOver(arrayFunc) { - return flatRest(function(iteratees) { + return flatRest(iteratees => { iteratees = arrayMap(iteratees, baseUnary(baseIteratee)); return baseRest(function(args) { var thisArg = this; - return arrayFunc(iteratees, function(iteratee) { - return apply(iteratee, thisArg, args); - }); + return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args)); }); }); } diff --git a/_createRange.js b/_createRange.js index 51b427e67..2dbdeb6c5 100644 --- a/_createRange.js +++ b/_createRange.js @@ -10,7 +10,7 @@ import toFinite from './toFinite.js'; * @returns {Function} Returns the new range function. */ function createRange(fromRight) { - return function(start, end, step) { + return (start, end, step) => { if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { end = step = undefined; } diff --git a/_createRelationalOperation.js b/_createRelationalOperation.js index ea208c6a0..5bee50b23 100644 --- a/_createRelationalOperation.js +++ b/_createRelationalOperation.js @@ -8,7 +8,7 @@ import toNumber from './toNumber.js'; * @returns {Function} Returns the new relational operation function. */ function createRelationalOperation(operator) { - return function(value, other) { + return (value, other) => { if (!(typeof value == 'string' && typeof other == 'string')) { value = toNumber(value); other = toNumber(other); diff --git a/_createRound.js b/_createRound.js index 8b3edab7b..2f1f64707 100644 --- a/_createRound.js +++ b/_createRound.js @@ -14,7 +14,7 @@ var nativeMin = Math.min; */ function createRound(methodName) { var func = Math[methodName]; - return function(number, precision) { + return (number, precision) => { number = toNumber(number); precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); if (precision) { diff --git a/_createSet.js b/_createSet.js index ead1dd70d..811d1109a 100644 --- a/_createSet.js +++ b/_createSet.js @@ -12,8 +12,6 @@ var INFINITY = 1 / 0; * @param {Array} values The values to add to the set. * @returns {Object} Returns the new set. */ -var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { - return new Set(values); -}; +var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : values => new Set(values); export default createSet; diff --git a/_createToPairs.js b/_createToPairs.js index 433d654b6..735a3044c 100644 --- a/_createToPairs.js +++ b/_createToPairs.js @@ -15,7 +15,7 @@ var mapTag = '[object Map]', * @returns {Function} Returns the new pairs function. */ function createToPairs(keysFunc) { - return function(object) { + return object => { var tag = getTag(object); if (tag == mapTag) { return mapToArray(object); diff --git a/_defineProperty.js b/_defineProperty.js index 826fc1dc6..e94f8fa47 100644 --- a/_defineProperty.js +++ b/_defineProperty.js @@ -1,11 +1,11 @@ import getNative from './_getNative.js'; -var defineProperty = (function() { +var defineProperty = ((() => { try { var func = getNative(Object, 'defineProperty'); func({}, '', {}); return func; } catch (e) {} -}()); +})()); export default defineProperty; diff --git a/_equalArrays.js b/_equalArrays.js index 77cafd960..97fa24474 100644 --- a/_equalArrays.js +++ b/_equalArrays.js @@ -58,7 +58,7 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { } // Recursively compare arrays (susceptible to call stack limits). if (seen) { - if (!arraySome(other, function(othValue, othIndex) { + if (!arraySome(other, (othValue, othIndex) => { if (!cacheHas(seen, othIndex) && (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { return seen.push(othIndex); diff --git a/_getData.js b/_getData.js index 36265ebdd..237c60a9a 100644 --- a/_getData.js +++ b/_getData.js @@ -8,8 +8,6 @@ import noop from './noop.js'; * @param {Function} func The function to query. * @returns {*} Returns the metadata for `func`. */ -var getData = !metaMap ? noop : function(func) { - return metaMap.get(func); -}; +var getData = !metaMap ? noop : func => metaMap.get(func); export default getData; diff --git a/_getSymbols.js b/_getSymbols.js index 474442abc..985337634 100644 --- a/_getSymbols.js +++ b/_getSymbols.js @@ -17,14 +17,12 @@ var nativeGetSymbols = Object.getOwnPropertySymbols; * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ -var getSymbols = !nativeGetSymbols ? stubArray : function(object) { +var getSymbols = !nativeGetSymbols ? stubArray : object => { if (object == null) { return []; } object = Object(object); - return arrayFilter(nativeGetSymbols(object), function(symbol) { - return propertyIsEnumerable.call(object, symbol); - }); + return arrayFilter(nativeGetSymbols(object), symbol => propertyIsEnumerable.call(object, symbol)); }; export default getSymbols; diff --git a/_getSymbolsIn.js b/_getSymbolsIn.js index 5f33b71e8..3e5dd4ef9 100644 --- a/_getSymbolsIn.js +++ b/_getSymbolsIn.js @@ -13,7 +13,7 @@ var nativeGetSymbols = Object.getOwnPropertySymbols; * @param {Object} object The object to query. * @returns {Array} Returns the array of symbols. */ -var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { +var getSymbolsIn = !nativeGetSymbols ? stubArray : object => { var result = []; while (object) { arrayPush(result, getSymbols(object)); diff --git a/_getTag.js b/_getTag.js index 0c86db0f9..0ccc0ee83 100644 --- a/_getTag.js +++ b/_getTag.js @@ -37,7 +37,7 @@ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || (Promise && getTag(Promise.resolve()) != promiseTag) || (Set && getTag(new Set) != setTag) || (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { + getTag = value => { var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : ''; diff --git a/_isMasked.js b/_isMasked.js index e3f9d6f4f..ffc1a3dfa 100644 --- a/_isMasked.js +++ b/_isMasked.js @@ -1,10 +1,10 @@ import coreJsData from './_coreJsData.js'; /** Used to detect methods masquerading as native. */ -var maskSrcKey = (function() { +var maskSrcKey = ((() => { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); return uid ? ('Symbol(src)_1.' + uid) : ''; -}()); +})()); /** * Checks if `func` has its source masked. diff --git a/_mapToArray.js b/_mapToArray.js index 82346d500..ce1729dfb 100644 --- a/_mapToArray.js +++ b/_mapToArray.js @@ -9,7 +9,7 @@ function mapToArray(map) { var index = -1, result = Array(map.size); - map.forEach(function(value, key) { + map.forEach((value, key) => { result[++index] = [key, value]; }); return result; diff --git a/_matchesStrictComparable.js b/_matchesStrictComparable.js index 531ffb3d0..ddcabefa7 100644 --- a/_matchesStrictComparable.js +++ b/_matchesStrictComparable.js @@ -8,7 +8,7 @@ * @returns {Function} Returns the new spec function. */ function matchesStrictComparable(key, srcValue) { - return function(object) { + return object => { if (object == null) { return false; } diff --git a/_memoizeCapped.js b/_memoizeCapped.js index d2b93994d..007be5679 100644 --- a/_memoizeCapped.js +++ b/_memoizeCapped.js @@ -12,7 +12,7 @@ var MAX_MEMOIZE_SIZE = 500; * @returns {Function} Returns the new memoized function. */ function memoizeCapped(func) { - var result = memoize(func, function(key) { + var result = memoize(func, key => { if (cache.size === MAX_MEMOIZE_SIZE) { cache.clear(); } diff --git a/_nodeUtil.js b/_nodeUtil.js index 467331693..7a45760a5 100644 --- a/_nodeUtil.js +++ b/_nodeUtil.js @@ -13,10 +13,10 @@ var moduleExports = freeModule && freeModule.exports === freeExports; var freeProcess = moduleExports && freeGlobal.process; /** Used to access faster Node.js helpers. */ -var nodeUtil = (function() { +var nodeUtil = ((() => { try { return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} -}()); +})()); export default nodeUtil; diff --git a/_overArg.js b/_overArg.js index 93bafe395..d286b7fb3 100644 --- a/_overArg.js +++ b/_overArg.js @@ -7,9 +7,7 @@ * @returns {Function} Returns the new function. */ function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; + return arg => func(transform(arg)); } export default overArg; diff --git a/_setToArray.js b/_setToArray.js index fdf823ccf..2eb13f7c7 100644 --- a/_setToArray.js +++ b/_setToArray.js @@ -9,7 +9,7 @@ function setToArray(set) { var index = -1, result = Array(set.size); - set.forEach(function(value) { + set.forEach(value => { result[++index] = value; }); return result; diff --git a/_stringToPath.js b/_stringToPath.js index f0617e7de..01f37112e 100644 --- a/_stringToPath.js +++ b/_stringToPath.js @@ -14,12 +14,12 @@ var reEscapeChar = /\\(\\)?/g; * @param {string} string The string to convert. * @returns {Array} Returns the property path array. */ -var stringToPath = memoizeCapped(function(string) { +var stringToPath = memoizeCapped(string => { var result = []; if (reLeadingDot.test(string)) { result.push(''); } - string.replace(rePropName, function(match, number, quote, string) { + string.replace(rePropName, (match, number, quote, string) => { result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); }); return result; diff --git a/_updateWrapDetails.js b/_updateWrapDetails.js index 69ecc1ec4..8a670cded 100644 --- a/_updateWrapDetails.js +++ b/_updateWrapDetails.js @@ -34,7 +34,7 @@ var wrapFlags = [ * @returns {Array} Returns `details`. */ function updateWrapDetails(details, bitmask) { - arrayEach(wrapFlags, function(pair) { + arrayEach(wrapFlags, pair => { var value = '_.' + pair[0]; if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { details.push(value); diff --git a/add.js b/add.js index b17f10771..8531113da 100644 --- a/add.js +++ b/add.js @@ -15,8 +15,6 @@ import createMathOperation from './_createMathOperation.js'; * _.add(6, 4); * // => 10 */ -var add = createMathOperation(function(augend, addend) { - return augend + addend; -}, 0); +var add = createMathOperation((augend, addend) => augend + addend, 0); export default add; diff --git a/assignIn.js b/assignIn.js index 8aab0e095..8ca13870f 100644 --- a/assignIn.js +++ b/assignIn.js @@ -33,7 +33,7 @@ import keysIn from './keysIn.js'; * _.assignIn({ 'a': 0 }, new Foo, new Bar); * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } */ -var assignIn = createAssigner(function(object, source) { +var assignIn = createAssigner((object, source) => { copyObject(source, keysIn(source), object); }); diff --git a/assignInWith.js b/assignInWith.js index c7864a192..51d646a54 100644 --- a/assignInWith.js +++ b/assignInWith.js @@ -31,7 +31,7 @@ import keysIn from './keysIn.js'; * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ -var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { +var assignInWith = createAssigner((object, source, srcIndex, customizer) => { copyObject(source, keysIn(source), object, customizer); }); diff --git a/assignWith.js b/assignWith.js index f19d7c5b4..0e815896f 100644 --- a/assignWith.js +++ b/assignWith.js @@ -30,7 +30,7 @@ import keys from './keys.js'; * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ -var assignWith = createAssigner(function(object, source, srcIndex, customizer) { +var assignWith = createAssigner((object, source, srcIndex, customizer) => { copyObject(source, keys(source), object, customizer); }); diff --git a/attempt.js b/attempt.js index ff4df2813..b7e73b736 100644 --- a/attempt.js +++ b/attempt.js @@ -24,7 +24,7 @@ import isError from './isError.js'; * elements = []; * } */ -var attempt = baseRest(function(func, args) { +var attempt = baseRest((func, args) => { try { return apply(func, undefined, args); } catch (e) { diff --git a/bind.js b/bind.js index 4bc03b320..37cd602bb 100644 --- a/bind.js +++ b/bind.js @@ -42,7 +42,7 @@ var WRAP_BIND_FLAG = 1, * bound('hi'); * // => 'hi fred!' */ -var bind = baseRest(function(func, thisArg, partials) { +var bind = baseRest((func, thisArg, partials) => { var bitmask = WRAP_BIND_FLAG; if (partials.length) { var holders = replaceHolders(partials, getHolder(bind)); diff --git a/bindAll.js b/bindAll.js index 37ae093a6..0e4dcb4a9 100644 --- a/bindAll.js +++ b/bindAll.js @@ -30,8 +30,8 @@ import toKey from './_toKey.js'; * jQuery(element).on('click', view.click); * // => Logs 'clicked docs' when clicked. */ -var bindAll = flatRest(function(object, methodNames) { - arrayEach(methodNames, function(key) { +var bindAll = flatRest((object, methodNames) => { + arrayEach(methodNames, key => { key = toKey(key); baseAssignValue(object, key, bind(object[key], object)); }); diff --git a/bindKey.js b/bindKey.js index fbbfa2987..a7c02cf0b 100644 --- a/bindKey.js +++ b/bindKey.js @@ -53,7 +53,7 @@ var WRAP_BIND_FLAG = 1, * bound('hi'); * // => 'hiya fred!' */ -var bindKey = baseRest(function(object, key, partials) { +var bindKey = baseRest((object, key, partials) => { var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; if (partials.length) { var holders = replaceHolders(partials, getHolder(bindKey)); diff --git a/camelCase.js b/camelCase.js index cc5ee9392..629e12379 100644 --- a/camelCase.js +++ b/camelCase.js @@ -21,7 +21,7 @@ import createCompounder from './_createCompounder.js'; * _.camelCase('__FOO_BAR__'); * // => 'fooBar' */ -var camelCase = createCompounder(function(result, word, index) { +var camelCase = createCompounder((result, word, index) => { word = word.toLowerCase(); return result + (index ? capitalize(word) : word); }); diff --git a/cond.js b/cond.js index 21eec1301..ab0cfab0b 100644 --- a/cond.js +++ b/cond.js @@ -39,7 +39,7 @@ function cond(pairs) { var length = pairs == null ? 0 : pairs.length, toIteratee = baseIteratee; - pairs = !length ? [] : arrayMap(pairs, function(pair) { + pairs = !length ? [] : arrayMap(pairs, pair => { if (typeof pair[1] != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } diff --git a/constant.js b/constant.js index c8dac98ca..885f1c22c 100644 --- a/constant.js +++ b/constant.js @@ -18,9 +18,7 @@ * // => true */ function constant(value) { - return function() { - return value; - }; + return () => value; } export default constant; diff --git a/countBy.js b/countBy.js index 2d0121308..6106887e1 100644 --- a/countBy.js +++ b/countBy.js @@ -29,7 +29,7 @@ var hasOwnProperty = objectProto.hasOwnProperty; * _.countBy(['one', 'two', 'three'], 'length'); * // => { '3': 2, '5': 1 } */ -var countBy = createAggregator(function(result, value, key) { +var countBy = createAggregator((result, value, key) => { if (hasOwnProperty.call(result, key)) { ++result[key]; } else { diff --git a/defaults.js b/defaults.js index b27d8818f..4552a4905 100644 --- a/defaults.js +++ b/defaults.js @@ -24,7 +24,7 @@ import customDefaultsAssignIn from './_customDefaultsAssignIn.js'; * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ -var defaults = baseRest(function(args) { +var defaults = baseRest(args => { args.push(undefined, customDefaultsAssignIn); return apply(assignInWith, undefined, args); }); diff --git a/defaultsDeep.js b/defaultsDeep.js index 409383e8f..fc6528150 100644 --- a/defaultsDeep.js +++ b/defaultsDeep.js @@ -22,7 +22,7 @@ import mergeWith from './mergeWith.js'; * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); * // => { 'a': { 'b': 2, 'c': 3 } } */ -var defaultsDeep = baseRest(function(args) { +var defaultsDeep = baseRest(args => { args.push(undefined, customDefaultsMerge); return apply(mergeWith, undefined, args); }); diff --git a/defer.js b/defer.js index 7c4c28416..1a6974a85 100644 --- a/defer.js +++ b/defer.js @@ -19,8 +19,6 @@ import baseRest from './_baseRest.js'; * }, 'deferred'); * // => Logs 'deferred' after one millisecond. */ -var defer = baseRest(function(func, args) { - return baseDelay(func, 1, args); -}); +var defer = baseRest((func, args) => baseDelay(func, 1, args)); export default defer; diff --git a/delay.js b/delay.js index d9b5eb468..681de4b07 100644 --- a/delay.js +++ b/delay.js @@ -21,8 +21,6 @@ import toNumber from './toNumber.js'; * }, 1000, 'later'); * // => Logs 'later' after one second. */ -var delay = baseRest(function(func, wait, args) { - return baseDelay(func, toNumber(wait) || 0, args); -}); +var delay = baseRest((func, wait, args) => baseDelay(func, toNumber(wait) || 0, args)); export default delay; diff --git a/difference.js b/difference.js index ddc1db57d..2ce272053 100644 --- a/difference.js +++ b/difference.js @@ -24,10 +24,8 @@ import isArrayLikeObject from './isArrayLikeObject.js'; * _.difference([2, 1], [2, 3]); * // => [1] */ -var difference = baseRest(function(array, values) { - return isArrayLikeObject(array) - ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) - : []; -}); +var difference = baseRest((array, values) => isArrayLikeObject(array) + ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) + : []); export default difference; diff --git a/differenceBy.js b/differenceBy.js index 983cc54fa..acc58d438 100644 --- a/differenceBy.js +++ b/differenceBy.js @@ -31,7 +31,7 @@ import last from './last.js'; * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); * // => [{ 'x': 2 }] */ -var differenceBy = baseRest(function(array, values) { +var differenceBy = baseRest((array, values) => { var iteratee = last(values); if (isArrayLikeObject(iteratee)) { iteratee = undefined; diff --git a/differenceWith.js b/differenceWith.js index 980a68cfc..4ac04c4a2 100644 --- a/differenceWith.js +++ b/differenceWith.js @@ -27,7 +27,7 @@ import last from './last.js'; * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); * // => [{ 'x': 2, 'y': 1 }] */ -var differenceWith = baseRest(function(array, values) { +var differenceWith = baseRest((array, values) => { var comparator = last(values); if (isArrayLikeObject(comparator)) { comparator = undefined; diff --git a/divide.js b/divide.js index f281786e7..b7f33eefe 100644 --- a/divide.js +++ b/divide.js @@ -15,8 +15,6 @@ import createMathOperation from './_createMathOperation.js'; * _.divide(6, 4); * // => 1.5 */ -var divide = createMathOperation(function(dividend, divisor) { - return dividend / divisor; -}, 1); +var divide = createMathOperation((dividend, divisor) => dividend / divisor, 1); export default divide; diff --git a/groupBy.js b/groupBy.js index ba83631cb..472babc63 100644 --- a/groupBy.js +++ b/groupBy.js @@ -30,7 +30,7 @@ var hasOwnProperty = objectProto.hasOwnProperty; * _.groupBy(['one', 'two', 'three'], 'length'); * // => { '3': ['one', 'two'], '5': ['three'] } */ -var groupBy = createAggregator(function(result, value, key) { +var groupBy = createAggregator((result, value, key) => { if (hasOwnProperty.call(result, key)) { result[key].push(value); } else { diff --git a/gte.js b/gte.js index 22c72b21b..9e255a820 100644 --- a/gte.js +++ b/gte.js @@ -23,8 +23,6 @@ import createRelationalOperation from './_createRelationalOperation.js'; * _.gte(1, 3); * // => false */ -var gte = createRelationalOperation(function(value, other) { - return value >= other; -}); +var gte = createRelationalOperation((value, other) => value >= other); export default gte; diff --git a/intersection.js b/intersection.js index 9d4ef19ec..b236e1faf 100644 --- a/intersection.js +++ b/intersection.js @@ -20,7 +20,7 @@ import castArrayLikeObject from './_castArrayLikeObject.js'; * _.intersection([2, 1], [2, 3]); * // => [2] */ -var intersection = baseRest(function(arrays) { +var intersection = baseRest(arrays => { var mapped = arrayMap(arrays, castArrayLikeObject); return (mapped.length && mapped[0] === arrays[0]) ? baseIntersection(mapped) diff --git a/intersectionBy.js b/intersectionBy.js index 6886f908a..28b36b752 100644 --- a/intersectionBy.js +++ b/intersectionBy.js @@ -28,7 +28,7 @@ import last from './last.js'; * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }] */ -var intersectionBy = baseRest(function(arrays) { +var intersectionBy = baseRest(arrays => { var iteratee = last(arrays), mapped = arrayMap(arrays, castArrayLikeObject); diff --git a/intersectionWith.js b/intersectionWith.js index 79e9424aa..5ecdede88 100644 --- a/intersectionWith.js +++ b/intersectionWith.js @@ -25,7 +25,7 @@ import last from './last.js'; * _.intersectionWith(objects, others, _.isEqual); * // => [{ 'x': 1, 'y': 2 }] */ -var intersectionWith = baseRest(function(arrays) { +var intersectionWith = baseRest(arrays => { var comparator = last(arrays), mapped = arrayMap(arrays, castArrayLikeObject); diff --git a/invert.js b/invert.js index 3ad074d87..1bb07b571 100644 --- a/invert.js +++ b/invert.js @@ -20,7 +20,7 @@ import identity from './identity.js'; * _.invert(object); * // => { '1': 'c', '2': 'b' } */ -var invert = createInverter(function(result, value, key) { +var invert = createInverter((result, value, key) => { result[value] = key; }, constant(identity)); diff --git a/invertBy.js b/invertBy.js index e29fc9d12..b97aabdd9 100644 --- a/invertBy.js +++ b/invertBy.js @@ -33,7 +33,7 @@ var hasOwnProperty = objectProto.hasOwnProperty; * }); * // => { 'group1': ['a', 'c'], 'group2': ['b'] } */ -var invertBy = createInverter(function(result, value, key) { +var invertBy = createInverter((result, value, key) => { if (hasOwnProperty.call(result, value)) { result[value].push(key); } else { diff --git a/invokeMap.js b/invokeMap.js index bab338328..66d7c0fee 100644 --- a/invokeMap.js +++ b/invokeMap.js @@ -27,12 +27,12 @@ import isArrayLike from './isArrayLike.js'; * _.invokeMap([123, 456], String.prototype.split, ''); * // => [['1', '2', '3'], ['4', '5', '6']] */ -var invokeMap = baseRest(function(collection, path, args) { +var invokeMap = baseRest((collection, path, args) => { var index = -1, isFunc = typeof path == 'function', result = isArrayLike(collection) ? Array(collection.length) : []; - baseEach(collection, function(value) { + baseEach(collection, value => { result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); }); return result; diff --git a/isArguments.js b/isArguments.js index 6c49fe578..6753346b3 100644 --- a/isArguments.js +++ b/isArguments.js @@ -28,9 +28,7 @@ var propertyIsEnumerable = objectProto.propertyIsEnumerable; * _.isArguments([1, 2, 3]); * // => false */ -var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { - return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && - !propertyIsEnumerable.call(value, 'callee'); -}; +var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') && + !propertyIsEnumerable.call(value, 'callee'); export default isArguments; diff --git a/kebabCase.js b/kebabCase.js index 1df34db96..2921e0c63 100644 --- a/kebabCase.js +++ b/kebabCase.js @@ -21,8 +21,6 @@ import createCompounder from './_createCompounder.js'; * _.kebabCase('__FOO_BAR__'); * // => 'foo-bar' */ -var kebabCase = createCompounder(function(result, word, index) { - return result + (index ? '-' : '') + word.toLowerCase(); -}); +var kebabCase = createCompounder((result, word, index) => result + (index ? '-' : '') + word.toLowerCase()); export default kebabCase; diff --git a/keyBy.js b/keyBy.js index 334952219..e7982b882 100644 --- a/keyBy.js +++ b/keyBy.js @@ -29,7 +29,7 @@ import createAggregator from './_createAggregator.js'; * _.keyBy(array, 'dir'); * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } */ -var keyBy = createAggregator(function(result, value, key) { +var keyBy = createAggregator((result, value, key) => { baseAssignValue(result, key, value); }); diff --git a/lodash.default.js b/lodash.default.js index e33e8d162..986c5b5ee 100644 --- a/lodash.default.js +++ b/lodash.default.js @@ -72,22 +72,20 @@ var nativeMax = Math.max, nativeMin = Math.min; // wrap `_.mixin` so it works when provided only one argument -var mixin = (function(func) { - return function(object, source, options) { - if (options == null) { - var isObj = isObject(source), - props = isObj && keys(source), - methodNames = props && props.length && baseFunctions(source, props); +var mixin = ((func => function(object, source, options) { + if (options == null) { + var isObj = isObject(source), + props = isObj && keys(source), + methodNames = props && props.length && baseFunctions(source, props); - if (!(methodNames ? methodNames.length : isObj)) { - options = source; - source = object; - object = this; - } + if (!(methodNames ? methodNames.length : isObj)) { + options = source; + source = object; + object = this; } - return func(object, source, options); - }; -}(_mixin)); + } + return func(object, source, options); +})(_mixin)); // Add methods that return wrapped values in chain sequences. lodash.after = func.after; @@ -403,15 +401,15 @@ lodash.each = collection.forEach; lodash.eachRight = collection.forEachRight; lodash.first = array.head; -mixin(lodash, (function() { +mixin(lodash, ((() => { var source = {}; - baseForOwn(lodash, function(func, methodName) { + baseForOwn(lodash, (func, methodName) => { if (!hasOwnProperty.call(lodash.prototype, methodName)) { source[methodName] = func; } }); return source; -}()), { 'chain': false }); +})()), { 'chain': false }); /** * The semantic version number. @@ -424,12 +422,12 @@ lodash.VERSION = VERSION; (lodash.templateSettings = string.templateSettings).imports._ = lodash; // Assign default placeholders. -arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { +arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], methodName => { lodash[methodName].placeholder = lodash; }); // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. -arrayEach(['drop', 'take'], function(methodName, index) { +arrayEach(['drop', 'take'], (methodName, index) => { LazyWrapper.prototype[methodName] = function(n) { n = n === undefined ? 1 : nativeMax(toInteger(n), 0); @@ -454,7 +452,7 @@ arrayEach(['drop', 'take'], function(methodName, index) { }); // Add `LazyWrapper` methods that accept an `iteratee` value. -arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { +arrayEach(['filter', 'map', 'takeWhile'], (methodName, index) => { var type = index + 1, isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; @@ -470,7 +468,7 @@ arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { }); // Add `LazyWrapper` methods for `_.head` and `_.last`. -arrayEach(['head', 'last'], function(methodName, index) { +arrayEach(['head', 'last'], (methodName, index) => { var takeName = 'take' + (index ? 'Right' : ''); LazyWrapper.prototype[methodName] = function() { @@ -479,7 +477,7 @@ arrayEach(['head', 'last'], function(methodName, index) { }); // Add `LazyWrapper` methods for `_.initial` and `_.tail`. -arrayEach(['initial', 'tail'], function(methodName, index) { +arrayEach(['initial', 'tail'], (methodName, index) => { var dropName = 'drop' + (index ? '' : 'Right'); LazyWrapper.prototype[methodName] = function() { @@ -503,9 +501,7 @@ LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { if (typeof path == 'function') { return new LazyWrapper(this); } - return this.map(function(value) { - return baseInvoke(value, path, args); - }); + return this.map(value => baseInvoke(value, path, args)); }); LazyWrapper.prototype.reject = function(predicate) { @@ -540,7 +536,7 @@ LazyWrapper.prototype.toArray = function() { }; // Add `LazyWrapper` methods to `lodash.prototype`. -baseForOwn(LazyWrapper.prototype, function(func, methodName) { +baseForOwn(LazyWrapper.prototype, (func, methodName) => { var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], @@ -556,7 +552,7 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) { iteratee = args[0], useLazy = isLazy || isArray(value); - var interceptor = function(value) { + var interceptor = value => { var result = lodashFunc.apply(lodash, arrayPush([value], args)); return (isTaker && chainAll) ? result[0] : result; }; @@ -585,7 +581,7 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) { }); // Add `Array` methods to `lodash.prototype`. -arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { +arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], methodName => { var func = arrayProto[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', retUnwrapped = /^(?:pop|shift)$/.test(methodName); @@ -596,14 +592,12 @@ arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(method var value = this.value(); return func.apply(isArray(value) ? value : [], args); } - return this[chainName](function(value) { - return func.apply(isArray(value) ? value : [], args); - }); + return this[chainName](value => func.apply(isArray(value) ? value : [], args)); }; }); // Map minified method names to their real names. -baseForOwn(LazyWrapper.prototype, function(func, methodName) { +baseForOwn(LazyWrapper.prototype, (func, methodName) => { var lodashFunc = lodash[methodName]; if (lodashFunc) { var key = (lodashFunc.name + ''), diff --git a/lowerCase.js b/lowerCase.js index 570d3b602..46286b253 100644 --- a/lowerCase.js +++ b/lowerCase.js @@ -20,8 +20,6 @@ import createCompounder from './_createCompounder.js'; * _.lowerCase('__FOO_BAR__'); * // => 'foo bar' */ -var lowerCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + word.toLowerCase(); -}); +var lowerCase = createCompounder((result, word, index) => result + (index ? ' ' : '') + word.toLowerCase()); export default lowerCase; diff --git a/lte.js b/lte.js index 50c90a9c3..bd8bcd8c7 100644 --- a/lte.js +++ b/lte.js @@ -23,8 +23,6 @@ import createRelationalOperation from './_createRelationalOperation.js'; * _.lte(3, 1); * // => false */ -var lte = createRelationalOperation(function(value, other) { - return value <= other; -}); +var lte = createRelationalOperation((value, other) => value <= other); export default lte; diff --git a/mapKeys.js b/mapKeys.js index 24fc6899f..7b4b5b071 100644 --- a/mapKeys.js +++ b/mapKeys.js @@ -27,7 +27,7 @@ function mapKeys(object, iteratee) { var result = {}; iteratee = baseIteratee(iteratee, 3); - baseForOwn(object, function(value, key, object) { + baseForOwn(object, (value, key, object) => { baseAssignValue(result, iteratee(value, key, object), value); }); return result; diff --git a/mapValues.js b/mapValues.js index bcc48e070..c50f33caf 100644 --- a/mapValues.js +++ b/mapValues.js @@ -34,7 +34,7 @@ function mapValues(object, iteratee) { var result = {}; iteratee = baseIteratee(iteratee, 3); - baseForOwn(object, function(value, key, object) { + baseForOwn(object, (value, key, object) => { baseAssignValue(result, key, iteratee(value, key, object)); }); return result; diff --git a/merge.js b/merge.js index 9aab6283a..3c74c7899 100644 --- a/merge.js +++ b/merge.js @@ -32,7 +32,7 @@ import createAssigner from './_createAssigner.js'; * _.merge(object, other); * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } */ -var merge = createAssigner(function(object, source, srcIndex) { +var merge = createAssigner((object, source, srcIndex) => { baseMerge(object, source, srcIndex); }); diff --git a/mergeWith.js b/mergeWith.js index 6b7e0982d..e78913d27 100644 --- a/mergeWith.js +++ b/mergeWith.js @@ -32,7 +32,7 @@ import createAssigner from './_createAssigner.js'; * _.mergeWith(object, other, customizer); * // => { 'a': [1, 3], 'b': [2, 4] } */ -var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { +var mergeWith = createAssigner((object, source, srcIndex, customizer) => { baseMerge(object, source, srcIndex, customizer); }); diff --git a/method.js b/method.js index 9daed7881..7b795d89b 100644 --- a/method.js +++ b/method.js @@ -25,10 +25,6 @@ import baseRest from './_baseRest.js'; * _.map(objects, _.method(['a', 'b'])); * // => [2, 1] */ -var method = baseRest(function(path, args) { - return function(object) { - return baseInvoke(object, path, args); - }; -}); +var method = baseRest((path, args) => object => baseInvoke(object, path, args)); export default method; diff --git a/methodOf.js b/methodOf.js index 1a4d98de7..dfd3d38b7 100644 --- a/methodOf.js +++ b/methodOf.js @@ -24,10 +24,6 @@ import baseRest from './_baseRest.js'; * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); * // => [2, 0] */ -var methodOf = baseRest(function(object, args) { - return function(path) { - return baseInvoke(object, path, args); - }; -}); +var methodOf = baseRest((object, args) => path => baseInvoke(object, path, args)); export default methodOf; diff --git a/multiply.js b/multiply.js index 19aba7251..0584093f2 100644 --- a/multiply.js +++ b/multiply.js @@ -15,8 +15,6 @@ import createMathOperation from './_createMathOperation.js'; * _.multiply(6, 4); * // => 24 */ -var multiply = createMathOperation(function(multiplier, multiplicand) { - return multiplier * multiplicand; -}, 1); +var multiply = createMathOperation((multiplier, multiplicand) => multiplier * multiplicand, 1); export default multiply; diff --git a/now.js b/now.js index 096807b0f..f31771cc1 100644 --- a/now.js +++ b/now.js @@ -16,8 +16,6 @@ import root from './_root.js'; * }, _.now()); * // => Logs the number of milliseconds it took for the deferred invocation. */ -var now = function() { - return root.Date.now(); -}; +var now = () => root.Date.now(); export default now; diff --git a/nthArg.js b/nthArg.js index be3a4cccc..76f474941 100644 --- a/nthArg.js +++ b/nthArg.js @@ -24,9 +24,7 @@ import toInteger from './toInteger.js'; */ function nthArg(n) { n = toInteger(n); - return baseRest(function(args) { - return baseNth(args, n); - }); + return baseRest(args => baseNth(args, n)); } export default nthArg; diff --git a/overArgs.js b/overArgs.js index c9409f402..a4856cec0 100644 --- a/overArgs.js +++ b/overArgs.js @@ -41,7 +41,7 @@ var nativeMin = Math.min; * func(10, 5); * // => [100, 10] */ -var overArgs = castRest(function(func, transforms) { +var overArgs = castRest((func, transforms) => { transforms = (transforms.length == 1 && isArray(transforms[0])) ? arrayMap(transforms[0], baseUnary(baseIteratee)) : arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee)); diff --git a/pick.js b/pick.js index fb849922b..d7ded1a9f 100644 --- a/pick.js +++ b/pick.js @@ -18,8 +18,6 @@ import flatRest from './_flatRest.js'; * _.pick(object, ['a', 'c']); * // => { 'a': 1, 'c': 3 } */ -var pick = flatRest(function(object, paths) { - return object == null ? {} : basePick(object, paths); -}); +var pick = flatRest((object, paths) => object == null ? {} : basePick(object, paths)); export default pick; diff --git a/pickBy.js b/pickBy.js index 4ff3598f5..9041152ca 100644 --- a/pickBy.js +++ b/pickBy.js @@ -25,13 +25,9 @@ function pickBy(object, predicate) { if (object == null) { return {}; } - var props = arrayMap(getAllKeysIn(object), function(prop) { - return [prop]; - }); + var props = arrayMap(getAllKeysIn(object), prop => [prop]); predicate = baseIteratee(predicate); - return basePickBy(object, props, function(value, path) { - return predicate(value, path[0]); - }); + return basePickBy(object, props, (value, path) => predicate(value, path[0])); } export default pickBy; diff --git a/propertyOf.js b/propertyOf.js index 457c7591c..2641b78e4 100644 --- a/propertyOf.js +++ b/propertyOf.js @@ -22,9 +22,7 @@ import baseGet from './_baseGet.js'; * // => [2, 0] */ function propertyOf(object) { - return function(path) { - return object == null ? undefined : baseGet(object, path); - }; + return path => object == null ? undefined : baseGet(object, path); } export default propertyOf; diff --git a/pullAt.js b/pullAt.js index 23213c73a..71806d9ee 100644 --- a/pullAt.js +++ b/pullAt.js @@ -29,13 +29,11 @@ import isIndex from './_isIndex.js'; * console.log(pulled); * // => ['b', 'd'] */ -var pullAt = flatRest(function(array, indexes) { +var pullAt = flatRest((array, indexes) => { var length = array == null ? 0 : array.length, result = baseAt(array, indexes); - basePullAt(array, arrayMap(indexes, function(index) { - return isIndex(index, length) ? +index : index; - }).sort(compareAscending)); + basePullAt(array, arrayMap(indexes, index => isIndex(index, length) ? +index : index).sort(compareAscending)); return result; }); diff --git a/rearg.js b/rearg.js index 6bdda0ce4..bc0c9be83 100644 --- a/rearg.js +++ b/rearg.js @@ -26,8 +26,6 @@ var WRAP_REARG_FLAG = 256; * rearged('b', 'c', 'a') * // => ['a', 'b', 'c'] */ -var rearg = flatRest(function(func, indexes) { - return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); -}); +var rearg = flatRest((func, indexes) => createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes)); export default rearg; diff --git a/snakeCase.js b/snakeCase.js index 83f163505..79236a58f 100644 --- a/snakeCase.js +++ b/snakeCase.js @@ -21,8 +21,8 @@ import createCompounder from './_createCompounder.js'; * _.snakeCase('--FOO-BAR--'); * // => 'foo_bar' */ -var snakeCase = createCompounder(function(result, word, index) { - return result + (index ? '_' : '') + word.toLowerCase(); -}); +const snakeCase = createCompounder((result, word, index) => + result + (index ? '_' : '') + word.toLowerCase() +); export default snakeCase; diff --git a/startCase.js b/startCase.js index 17f9cde3c..95db2ec44 100644 --- a/startCase.js +++ b/startCase.js @@ -22,8 +22,6 @@ import upperFirst from './upperFirst.js'; * _.startCase('__FOO_BAR__'); * // => 'FOO BAR' */ -var startCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + upperFirst(word); -}); +var startCase = createCompounder((result, word, index) => result + (index ? ' ' : '') + upperFirst(word)); export default startCase; diff --git a/subtract.js b/subtract.js index c2ca69123..dc238a551 100644 --- a/subtract.js +++ b/subtract.js @@ -15,8 +15,6 @@ import createMathOperation from './_createMathOperation.js'; * _.subtract(6, 4); * // => 2 */ -var subtract = createMathOperation(function(minuend, subtrahend) { - return minuend - subtrahend; -}, 0); +var subtract = createMathOperation((minuend, subtrahend) => minuend - subtrahend, 0); export default subtract; diff --git a/template.js b/template.js index 17873472c..03bb8843f 100644 --- a/template.js +++ b/template.js @@ -164,7 +164,14 @@ function template(string, options, guard) { // Use a sourceURL for easier debugging. var sourceURL = 'sourceURL' in options ? '//# sourceURL=' + options.sourceURL + '\n' : ''; - string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { + string.replace(reDelimiters, ( + match, + escapeValue, + interpolateValue, + esTemplateValue, + evaluateValue, + offset + ) => { interpolateValue || (interpolateValue = esTemplateValue); // Escape characters that can't be included in string literals. @@ -221,10 +228,8 @@ function template(string, options, guard) { source + 'return __p\n}'; - var result = attempt(function() { - return Function(importsKeys, sourceURL + 'return ' + source) - .apply(undefined, importsValues); - }); + var result = attempt(() => Function(importsKeys, sourceURL + 'return ' + source) + .apply(undefined, importsValues)); // Provide the compiled function's source by its `toString` method or // the `source` property as a convenience for inlining compiled templates. diff --git a/transform.js b/transform.js index d6f9456ca..05ade4c1f 100644 --- a/transform.js +++ b/transform.js @@ -56,9 +56,7 @@ function transform(object, iteratee, accumulator) { accumulator = {}; } } - (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iteratee(accumulator, value, index, object); - }); + (isArrLike ? arrayEach : baseForOwn)(object, (value, index, object) => iteratee(accumulator, value, index, object)); return accumulator; } diff --git a/unionWith.js b/unionWith.js index 54cafe1cd..d0c9c52e1 100644 --- a/unionWith.js +++ b/unionWith.js @@ -25,7 +25,7 @@ import last from './last.js'; * _.unionWith(objects, others, _.isEqual); * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] */ -var unionWith = baseRest(function(arrays) { +var unionWith = baseRest(arrays => { var comparator = last(arrays); comparator = typeof comparator == 'function' ? comparator : undefined; return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); diff --git a/unzip.js b/unzip.js index e3f7a604a..db5075011 100644 --- a/unzip.js +++ b/unzip.js @@ -31,15 +31,13 @@ function unzip(array) { return []; } var length = 0; - array = arrayFilter(array, function(group) { + array = arrayFilter(array, group => { if (isArrayLikeObject(group)) { length = nativeMax(group.length, length); return true; } }); - return baseTimes(length, function(index) { - return arrayMap(array, baseProperty(index)); - }); + return baseTimes(length, index => arrayMap(array, baseProperty(index))); } export default unzip; diff --git a/unzipWith.js b/unzipWith.js index c588d08bc..7006bf9e1 100644 --- a/unzipWith.js +++ b/unzipWith.js @@ -31,9 +31,7 @@ function unzipWith(array, iteratee) { if (iteratee == null) { return result; } - return arrayMap(result, function(group) { - return apply(iteratee, undefined, group); - }); + return arrayMap(result, group => apply(iteratee, undefined, group)); } export default unzipWith; diff --git a/upperCase.js b/upperCase.js index b5cf8578b..1b15168a0 100644 --- a/upperCase.js +++ b/upperCase.js @@ -20,8 +20,8 @@ import createCompounder from './_createCompounder.js'; * _.upperCase('__foo_bar__'); * // => 'FOO BAR' */ -var upperCase = createCompounder(function(result, word, index) { - return result + (index ? ' ' : '') + word.toUpperCase(); -}); +const upperCase = createCompounder((result, word, index) => + result + (index ? ' ' : '') + word.toUpperCase() +); export default upperCase; diff --git a/xorWith.js b/xorWith.js index b24e98b26..d9be42a45 100644 --- a/xorWith.js +++ b/xorWith.js @@ -1,5 +1,4 @@ import arrayFilter from './_arrayFilter.js'; -import baseRest from './_baseRest.js'; import baseXor from './_baseXor.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -25,10 +24,10 @@ import last from './last.js'; * _.xorWith(objects, others, _.isEqual); * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] */ -var xorWith = baseRest(function(arrays) { - var comparator = last(arrays); +function xorWith(...arrays) { + let comparator = last(arrays); comparator = typeof comparator == 'function' ? comparator : undefined; return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); -}); +} export default xorWith;