Skip to content

Commit

Permalink
array: reduce function has length as 4th argument
Browse files Browse the repository at this point in the history
  • Loading branch information
hbbio committed Apr 11, 2024
1 parent d96ff86 commit fe6ac26
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const reduce = <
>(
proxy: SheetProxy,
arr: CellArray<T>,
fn: (acc: R, elt: T, index?: number) => R,
fn: (acc: R, elt: T, index?: number, length?: number) => R,
init: R,
name = "reduce",
nf?: NF
Expand All @@ -178,7 +178,11 @@ export const reduce = <
coll(
proxy.mapNoPrevious(
cells,
(..._cells) => _cells.reduce(fn, init),
(..._cells) =>
_cells.reduce(
(acc, elt, i) => fn(acc, elt, i, _cells.length),
init
),
"_reduce"
)
),
Expand Down

0 comments on commit fe6ac26

Please sign in to comment.