mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Apply more let/const transforms.
This commit is contained in:
23
_baseUniq.js
23
_baseUniq.js
@@ -6,7 +6,7 @@ import createSet from './_createSet.js';
|
||||
import setToArray from './_setToArray.js';
|
||||
|
||||
/** Used as the size to enable large array optimizations. */
|
||||
var LARGE_ARRAY_SIZE = 200;
|
||||
const LARGE_ARRAY_SIZE = 200;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
||||
@@ -18,19 +18,20 @@ var LARGE_ARRAY_SIZE = 200;
|
||||
* @returns {Array} Returns the new duplicate free array.
|
||||
*/
|
||||
function baseUniq(array, iteratee, comparator) {
|
||||
var index = -1,
|
||||
includes = arrayIncludes,
|
||||
length = array.length,
|
||||
isCommon = true,
|
||||
result = [],
|
||||
seen = result;
|
||||
let index = -1;
|
||||
let includes = arrayIncludes;
|
||||
let isCommon = true;
|
||||
|
||||
const length = array.length;
|
||||
const result = [];
|
||||
let seen = result;
|
||||
|
||||
if (comparator) {
|
||||
isCommon = false;
|
||||
includes = arrayIncludesWith;
|
||||
}
|
||||
else if (length >= LARGE_ARRAY_SIZE) {
|
||||
var set = iteratee ? null : createSet(array);
|
||||
const set = iteratee ? null : createSet(array);
|
||||
if (set) {
|
||||
return setToArray(set);
|
||||
}
|
||||
@@ -43,12 +44,12 @@ function baseUniq(array, iteratee, comparator) {
|
||||
}
|
||||
outer:
|
||||
while (++index < length) {
|
||||
var value = array[index],
|
||||
computed = iteratee ? iteratee(value) : value;
|
||||
let value = array[index];
|
||||
const computed = iteratee ? iteratee(value) : value;
|
||||
|
||||
value = (comparator || value !== 0) ? value : 0;
|
||||
if (isCommon && computed === computed) {
|
||||
var seenIndex = seen.length;
|
||||
let seenIndex = seen.length;
|
||||
while (seenIndex--) {
|
||||
if (seen[seenIndex] === computed) {
|
||||
continue outer;
|
||||
|
||||
Reference in New Issue
Block a user