We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 43a11c5 + 08da452 commit b45d100Copy full SHA for b45d100
src/lang.ts
@@ -232,22 +232,22 @@ export const maxBy = <T>(
232
};
233
234
export const sumBy = <T>(
235
- items: ReadonlyArray<T>,
+ items: ReadonlyArray<T> | undefined,
236
fn: (x: T) => number,
237
): number => {
238
let s = 0;
239
- for (const item of items) {
+ for (const item of items ?? []) {
240
s += fn(item);
241
}
242
return s;
243
244
245
export const countBy = <T>(
246
247
fn: (x: T) => boolean,
248
249
250
251
if (fn(item)) {
252
s++;
253
0 commit comments