mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Continue to use more ES2015.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
5
union.js
5
union.js
@@ -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;
|
||||
|
||||
@@ -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
5
xor.js
@@ -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;
|
||||
|
||||
4
xorBy.js
4
xorBy.js
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user