Browse Source

Avoids null return

main
Eric Amodio 1 year ago
parent
commit
ce200af478
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/system/iterable.ts

+ 2
- 2
src/system/iterable.ts View File

@ -99,11 +99,11 @@ export function forEach(source: Iterable | IterableIterator, fn: (item:
}
}
export function find<T>(source: Iterable<T> | IterableIterator<T>, predicate: (item: T) => boolean): T | null {
export function find<T>(source: Iterable<T> | IterableIterator<T>, predicate: (item: T) => boolean): T | undefined {
for (const item of source) {
if (predicate(item)) return item;
}
return null;
return undefined;
}
export function findIndex<T>(source: Iterable<T> | IterableIterator<T>, predicate: (item: T) => boolean): number {

Loading…
Cancel
Save