Skip to content

Commit 4c9c98e

Browse files
committed
get rid of for loops
1 parent 6a3116c commit 4c9c98e

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

packages/core/src/utils-hoist/object.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,9 @@ function _dropUndefinedKeys<T>(inputValue: T, memoizationMap: Map<unknown, unkno
239239
// Store mapping to handle circular references
240240
memoizationMap.set(inputValue, returnValue);
241241

242-
// Use direct indexing instead of forEach for better performance
243-
// eslint-disable-next-line @typescript-eslint/prefer-for-of
244-
for (let i = 0; i < inputValue.length; i++) {
245-
returnValue.push(_dropUndefinedKeys(inputValue[i], memoizationMap));
246-
}
242+
inputValue.forEach(value => {
243+
returnValue.push(_dropUndefinedKeys(value, memoizationMap));
244+
});
247245

248246
return returnValue as unknown as T;
249247
}
@@ -255,15 +253,12 @@ function _dropUndefinedKeys<T>(inputValue: T, memoizationMap: Map<unknown, unkno
255253

256254
const keys = Object.keys(inputValue);
257255

258-
// Use direct indexing instead of forEach for better performance
259-
// eslint-disable-next-line @typescript-eslint/prefer-for-of
260-
for (let i = 0; i < keys.length; i++) {
261-
const key = keys[i] as string;
256+
keys.forEach(key => {
262257
const val = inputValue[key];
263258
if (val !== undefined) {
264259
returnValue[key] = _dropUndefinedKeys(val, memoizationMap);
265260
}
266-
}
261+
});
267262

268263
return returnValue as T;
269264
}

0 commit comments

Comments
 (0)