Skip to content

Commit 7b09c1e

Browse files
committed
fix: fill result of splitArray
1 parent 1b42d11 commit 7b09c1e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/src/util.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,15 @@ function unimplemented(): never {
187187
throw new Error('not implemented')
188188
}
189189

190-
function splitArray<T>(arr: T[], chunkSize: number): T[][] {
190+
function splitArray<T>(arr: T[], chunkSize: number, fill: boolean = true): (T|null)[][] {
191191
const res = []
192192

193193
for (let i = 0; i < arr.length; i += chunkSize) {
194-
res.push(arr.slice(i, i + chunkSize))
194+
const slice: (T | null)[] = arr.slice(i, i + chunkSize)
195+
while (fill && slice.length < chunkSize) {
196+
slice.push(null);
197+
}
198+
res.push(slice)
195199
}
196200

197201
return res

0 commit comments

Comments
 (0)