Skip to content

Commit 0ef6f19

Browse files
committed
🐛 default to empty array in sumBy & countBy
1 parent 43a11c5 commit 0ef6f19

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/lang.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export const sumBy = <T>(
236236
fn: (x: T) => number,
237237
): number => {
238238
let s = 0;
239-
for (const item of items) {
239+
for (const item of items ?? []) {
240240
s += fn(item);
241241
}
242242
return s;
@@ -247,7 +247,7 @@ export const countBy = <T>(
247247
fn: (x: T) => boolean,
248248
): number => {
249249
let s = 0;
250-
for (const item of items) {
250+
for (const item of items ?? []) {
251251
if (fn(item)) {
252252
s++;
253253
}

0 commit comments

Comments
 (0)