Continue to use more ES2015.

This commit is contained in:
John-David Dalton
2017-01-03 23:07:06 -08:00
parent 1a1e462f80
commit 0e24641cb8
7 changed files with 21 additions and 21 deletions

View File

@@ -6,12 +6,12 @@
* @returns {Array} Returns the value-value pairs.
*/
function setToPairs(set) {
var index = -1,
result = Array(set.size);
let index = -1;
const result = Array(set.size);
set.forEach(function(value) {
result[++index] = [value, value];
});
set.forEach(value =>
result[++index] = [value, value]
);
return result;
}

View File

@@ -36,8 +36,7 @@ import createAggregator from './_createAggregator.js';
* _.partition(users, 'active');
* // => objects for [['fred'], ['barney', 'pebbles']]
*/
var partition = createAggregator(function(result, value, key) {
result[key ? 0 : 1].push(value);
}, function() { return [[], []]; });
const partition = createAggregator((result, value, key) =>
result[key ? 0 : 1].push(value), () => [[], []]);
export default partition;

View File

@@ -18,7 +18,8 @@ import isArrayLikeObject from './isArrayLikeObject.js';
* _.union([2], [1, 2]);
* // => [2, 1]
*/
const union = (...arrays) =>
baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
function union(...arrays) {
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
}
export default union;

View File

@@ -27,12 +27,12 @@ import last from './last.js';
* _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
const unionBy = (...arrays) => {
function unionBy(...arrays) {
let iteratee = last(arrays);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2));
};
}
export default unionBy;

5
xor.js
View File

@@ -20,7 +20,8 @@ import isArrayLikeObject from './isArrayLikeObject.js';
* _.xor([2, 1], [2, 3]);
* // => [1, 3]
*/
const xor = (...arrays) =>
baseXor(arrayFilter(arrays, isArrayLikeObject));
function xor(...arrays) {
return baseXor(arrayFilter(arrays, isArrayLikeObject));
}
export default xor;

View File

@@ -27,12 +27,12 @@ import last from './last.js';
* _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
const xorBy = (...arrays) => {
function xorBy(...arrays) {
let iteratee = last(arrays);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
return baseXor(arrayFilter(arrays, isArrayLikeObject), baseIteratee(iteratee, 2));
};
}
export default xorBy;

View File

@@ -1,4 +1,3 @@
import baseRest from './_baseRest.js';
import unzipWith from './unzipWith.js';
/**
@@ -21,12 +20,12 @@ import unzipWith from './unzipWith.js';
* });
* // => [111, 222]
*/
var zipWith = baseRest(function(arrays) {
var length = arrays.length,
iteratee = length > 1 ? arrays[length - 1] : undefined;
function zipWith(...arrays) {
const length = arrays.length;
let iteratee = length > 1 ? arrays[length - 1] : undefined;
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
return unzipWith(arrays, iteratee);
});
}
export default zipWith;