mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Use more for-of
This commit is contained in:
@@ -19,14 +19,12 @@ const LARGE_ARRAY_SIZE = 200
|
||||
* @returns {Array} Returns the new array of filtered values.
|
||||
*/
|
||||
function baseDifference(array, values, iteratee, comparator) {
|
||||
let index = -1
|
||||
let includes = arrayIncludes
|
||||
let isCommon = true
|
||||
const { length } = array
|
||||
const result = []
|
||||
const valuesLength = values.length
|
||||
|
||||
if (!length) {
|
||||
if (!array.length) {
|
||||
return result
|
||||
}
|
||||
if (iteratee) {
|
||||
@@ -42,8 +40,7 @@ function baseDifference(array, values, iteratee, comparator) {
|
||||
values = new SetCache(values)
|
||||
}
|
||||
outer:
|
||||
while (++index < length) {
|
||||
let value = array[index]
|
||||
for (let value of array) {
|
||||
const computed = iteratee == null ? value : iteratee(value)
|
||||
|
||||
value = (comparator || value !== 0) ? value : 0
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
*/
|
||||
function baseSum(array, iteratee) {
|
||||
let result
|
||||
let index = -1
|
||||
const { length } = array
|
||||
|
||||
while (++index < length) {
|
||||
const current = iteratee(array[index])
|
||||
for (value of array) {
|
||||
const current = iteratee(value)
|
||||
if (current !== undefined) {
|
||||
result = result === undefined ? current : (result + current)
|
||||
}
|
||||
|
||||
@@ -15,12 +15,7 @@ function copyObject(source, props, object, customizer) {
|
||||
const isNew = !object
|
||||
object || (object = {})
|
||||
|
||||
let index = -1
|
||||
const length = props.length
|
||||
|
||||
while (++index < length) {
|
||||
const key = props[index]
|
||||
|
||||
for (const key of props) {
|
||||
let newValue = customizer
|
||||
? customizer(object[key], source[key], key, object, source)
|
||||
: undefined
|
||||
|
||||
Reference in New Issue
Block a user