diff --git a/_baseAggregator.js b/_baseAggregator.js index 5bf1fdddc..b5710aae5 100644 --- a/_baseAggregator.js +++ b/_baseAggregator.js @@ -12,7 +12,7 @@ import baseEach from './_baseEach.js'; * @returns {Function} Returns `accumulator`. */ function baseAggregator(collection, setter, iteratee, accumulator) { - baseEach(collection, function(value, key, collection) { + baseEach(collection, (value, key, collection) => { setter(accumulator, value, iteratee(value), collection); }); return accumulator; diff --git a/_baseClone.js b/_baseClone.js index 41959eb47..324cce92c 100644 --- a/_baseClone.js +++ b/_baseClone.js @@ -19,12 +19,12 @@ import isObject from './isObject.js'; import keys from './keys.js'; /** Used to compose bitmasks for cloning. */ -var CLONE_DEEP_FLAG = 1, - CLONE_FLAT_FLAG = 2, - CLONE_SYMBOLS_FLAG = 4; +const CLONE_DEEP_FLAG = 1; +const CLONE_FLAT_FLAG = 2; +const CLONE_SYMBOLS_FLAG = 4; /** `Object#toString` result references. */ -var argsTag = '[object Arguments]', +const argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', diff --git a/_baseConforms.js b/_baseConforms.js index d7633c130..bd59720bc 100644 --- a/_baseConforms.js +++ b/_baseConforms.js @@ -9,10 +9,8 @@ import keys from './keys.js'; * @returns {Function} Returns the new spec function. */ function baseConforms(source) { - var props = keys(source); - return function(object) { - return baseConformsTo(object, source, props); - }; + const props = keys(source); + return object => baseConformsTo(object, source, props); } export default baseConforms; diff --git a/_baseCreate.js b/_baseCreate.js index ad1da382b..bb546324f 100644 --- a/_baseCreate.js +++ b/_baseCreate.js @@ -1,7 +1,7 @@ import isObject from './isObject.js'; /** Built-in value references. */ -var objectCreate = Object.create; +const objectCreate = Object.create; /** * The base implementation of `_.create` without support for assigning @@ -11,9 +11,9 @@ var objectCreate = Object.create; * @param {Object} proto The object to inherit from. * @returns {Object} Returns the new object. */ -var baseCreate = (function() { +const baseCreate = (() => { function object() {} - return function(proto) { + return proto => { if (!isObject(proto)) { return {}; } @@ -25,6 +25,6 @@ var baseCreate = (function() { object.prototype = undefined; return result; }; -}()); +})(); export default baseCreate; diff --git a/_baseDelay.js b/_baseDelay.js index 8cc5e27a2..8ed06977c 100644 --- a/_baseDelay.js +++ b/_baseDelay.js @@ -1,5 +1,5 @@ /** Error message constants. */ -var FUNC_ERROR_TEXT = 'Expected a function'; +const FUNC_ERROR_TEXT = 'Expected a function'; /** * The base implementation of `_.delay` and `_.defer` which accepts `args` @@ -15,7 +15,7 @@ function baseDelay(func, wait, args) { if (typeof func != 'function') { throw new TypeError(FUNC_ERROR_TEXT); } - return setTimeout(function() { func.apply(undefined, args); }, wait); + return setTimeout(() => func.apply(undefined, args), wait); } export default baseDelay; diff --git a/_baseEvery.js b/_baseEvery.js index 2154b4700..96964b9d5 100644 --- a/_baseEvery.js +++ b/_baseEvery.js @@ -10,8 +10,8 @@ import baseEach from './_baseEach.js'; * else `false` */ function baseEvery(collection, predicate) { - var result = true; - baseEach(collection, function(value, index, collection) { + let result = true; + baseEach(collection, (value, index, collection) => { result = !!predicate(value, index, collection); return result; }); diff --git a/_baseFilter.js b/_baseFilter.js index 4840ed609..4376c7908 100644 --- a/_baseFilter.js +++ b/_baseFilter.js @@ -9,8 +9,8 @@ import baseEach from './_baseEach.js'; * @returns {Array} Returns the new filtered array. */ function baseFilter(collection, predicate) { - var result = []; - baseEach(collection, function(value, index, collection) { + const result = []; + baseEach(collection, (value, index, collection) => { if (predicate(value, index, collection)) { result.push(value); } diff --git a/_baseFindKey.js b/_baseFindKey.js index 6d1932eed..d840ed875 100644 --- a/_baseFindKey.js +++ b/_baseFindKey.js @@ -10,8 +10,8 @@ * @returns {*} Returns the found element or its key, else `undefined`. */ function baseFindKey(collection, predicate, eachFunc) { - var result; - eachFunc(collection, function(value, key, collection) { + let result; + eachFunc(collection, (value, key, collection) => { if (predicate(value, key, collection)) { result = key; return false; diff --git a/_baseFunctions.js b/_baseFunctions.js index 35a875e96..c109f0ba4 100644 --- a/_baseFunctions.js +++ b/_baseFunctions.js @@ -11,9 +11,7 @@ import isFunction from './isFunction.js'; * @returns {Array} Returns the function names. */ function baseFunctions(object, props) { - return arrayFilter(props, function(key) { - return isFunction(object[key]); - }); + return arrayFilter(props, key => isFunction(object[key])); } export default baseFunctions; diff --git a/_baseIsNative.js b/_baseIsNative.js index 04c185431..63b2fe17e 100644 --- a/_baseIsNative.js +++ b/_baseIsNative.js @@ -7,23 +7,23 @@ import toSource from './_toSource.js'; * Used to match `RegExp` * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; +const reRegExpChar = /[\\^$.*+?()[\]{}|]/g; /** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; +const reIsHostCtor = /^\[object .+?Constructor\]$/; /** Used for built-in method references. */ -var funcProto = Function.prototype, - objectProto = Object.prototype; +const funcProto = Function.prototype; +const objectProto = Object.prototype; /** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; +const funcToString = funcProto.toString; /** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; +const hasOwnProperty = objectProto.hasOwnProperty; /** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + +const reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' ); @@ -40,7 +40,7 @@ function baseIsNative(value) { if (!isObject(value) || isMasked(value)) { return false; } - var pattern = isFunction(value) ? reIsNative : reIsHostCtor; + const pattern = isFunction(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } diff --git a/_baseMap.js b/_baseMap.js index c607c0191..0cc1933b1 100644 --- a/_baseMap.js +++ b/_baseMap.js @@ -10,10 +10,10 @@ import isArrayLike from './isArrayLike.js'; * @returns {Array} Returns the new mapped array. */ function baseMap(collection, iteratee) { - var index = -1, - result = isArrayLike(collection) ? Array(collection.length) : []; + let index = -1; + const result = isArrayLike(collection) ? Array(collection.length) : []; - baseEach(collection, function(value, key, collection) { + baseEach(collection, (value, key, collection) => { result[++index] = iteratee(value, key, collection); }); return result; diff --git a/_baseMerge.js b/_baseMerge.js index 37680f72f..dc1f309ab 100644 --- a/_baseMerge.js +++ b/_baseMerge.js @@ -20,13 +20,13 @@ function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } - baseFor(source, function(srcValue, key) { + baseFor(source, (srcValue, key) => { if (isObject(srcValue)) { stack || (stack = new Stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { - var newValue = customizer + const newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined; diff --git a/union.js b/union.js index eb5979e92..145cacc9c 100644 --- a/union.js +++ b/union.js @@ -1,5 +1,4 @@ import baseFlatten from './_baseFlatten.js'; -import baseRest from './_baseRest.js'; import baseUniq from './_baseUniq.js'; import isArrayLikeObject from './isArrayLikeObject.js'; @@ -19,8 +18,7 @@ import isArrayLikeObject from './isArrayLikeObject.js'; * _.union([2], [1, 2]); * // => [2, 1] */ -var union = baseRest(function(arrays) { - return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); -}); +const union = (...arrays) => + baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); export default union; diff --git a/unionBy.js b/unionBy.js index 53651b1eb..a81c48961 100644 --- a/unionBy.js +++ b/unionBy.js @@ -1,6 +1,5 @@ import baseFlatten from './_baseFlatten.js'; import baseIteratee from './_baseIteratee.js'; -import baseRest from './_baseRest.js'; import baseUniq from './_baseUniq.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -28,12 +27,12 @@ import last from './last.js'; * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ -var unionBy = baseRest(function(arrays) { - var iteratee = last(arrays); +const unionBy = (...arrays) => { + let iteratee = last(arrays); if (isArrayLikeObject(iteratee)) { iteratee = undefined; } return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2)); -}); +}; export default unionBy; diff --git a/without.js b/without.js index 5d994231a..21ca42f8a 100644 --- a/without.js +++ b/without.js @@ -1,5 +1,4 @@ import baseDifference from './_baseDifference.js'; -import baseRest from './_baseRest.js'; import isArrayLikeObject from './isArrayLikeObject.js'; /** @@ -22,10 +21,7 @@ import isArrayLikeObject from './isArrayLikeObject.js'; * _.without([2, 1, 2, 3], 1, 2); * // => [3] */ -var without = baseRest(function(array, values) { - return isArrayLikeObject(array) - ? baseDifference(array, values) - : []; -}); +const without = (array, ...values) => + isArrayLikeObject(array) ? baseDifference(array, values) : []; export default without; diff --git a/xor.js b/xor.js index c406c48e2..8fd4d0f7f 100644 --- a/xor.js +++ b/xor.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'; @@ -21,8 +20,7 @@ import isArrayLikeObject from './isArrayLikeObject.js'; * _.xor([2, 1], [2, 3]); * // => [1, 3] */ -var xor = baseRest(function(arrays) { - return baseXor(arrayFilter(arrays, isArrayLikeObject)); -}); +const xor = (...arrays) => + baseXor(arrayFilter(arrays, isArrayLikeObject)); export default xor; diff --git a/xorBy.js b/xorBy.js index f21d8ad91..5afbb53fb 100644 --- a/xorBy.js +++ b/xorBy.js @@ -1,6 +1,5 @@ import arrayFilter from './_arrayFilter.js'; import baseIteratee from './_baseIteratee.js'; -import baseRest from './_baseRest.js'; import baseXor from './_baseXor.js'; import isArrayLikeObject from './isArrayLikeObject.js'; import last from './last.js'; @@ -28,12 +27,12 @@ import last from './last.js'; * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 2 }] */ -var xorBy = baseRest(function(arrays) { - var iteratee = last(arrays); +const xorBy = (...arrays) => { + let iteratee = last(arrays); if (isArrayLikeObject(iteratee)) { iteratee = undefined; } return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2)); -}); +}; export default xorBy;