Skip to content

Commit 160fb68

Browse files
committed
DynamicArray: simplify forEach function definition
1 parent 87f5b9f commit 160fb68

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/lib/provable/dynamic-array.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,23 +270,15 @@ class DynamicArrayBase<ProvableValue = any, Value = any> {
270270
return newArray;
271271
}
272272

273-
forEach(f: (t: ProvableValue, isDummy: Bool) => void): void;
274-
forEach(f: (t: ProvableValue, isDummy: Bool, i: number) => void): void;
275273
/**
276274
* Iterate over all elements of the array.
277275
*
278276
* The callback will be passed an element and a boolean `isDummy` indicating
279277
* whether the value is part of the actual array. Optionally, an index can be
280278
* passed as a third argument (used in `forEachReversed`)
281279
*/
282-
forEach(f: (...args: any[]) => void): void {
283-
zip(this.array, this.#dummyMask()).forEach(([t, isDummy], i) => {
284-
if (f.length === 2) {
285-
f(t, isDummy);
286-
} else {
287-
f(t, isDummy, i);
288-
}
289-
});
280+
forEach(f: (t: ProvableValue, isDummy: Bool, i?: number) => void): void {
281+
zip(this.array, this.#dummyMask()).forEach(([t, isDummy], i) => f(t, isDummy, i));
290282
}
291283

292284
/**

0 commit comments

Comments
 (0)