Skip to content

Commit

Permalink
fix(types): make select more option-friendly
Browse files Browse the repository at this point in the history
By accepting `null` or undefined for the `condition` parameter, the `select` function now works better when dealing with optional values.
  • Loading branch information
aleclarson committed Jul 18, 2024
1 parent a1349e9 commit c9cfcd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/array/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
export function select<T, U>(
array: readonly T[],
mapper: (item: T, index: number) => U,
condition: (item: T, index: number) => boolean,
condition: ((item: T, index: number) => boolean) | null | undefined,
): U[]

export function select<T, U>(
Expand All @@ -28,7 +28,7 @@ export function select<T, U>(
export function select<T, U>(
array: readonly T[],
mapper: (item: T, index: number) => U,
condition?: (item: T, index: number) => boolean,
condition?: ((item: T, index: number) => boolean) | null,
): U[] {
if (!array) {
return []
Expand Down

0 comments on commit c9cfcd0

Please sign in to comment.