Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/effect/src/Effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3756,8 +3756,9 @@ export const raceFirst: {
* @example
* ```ts
* import { Effect } from "effect"
* import { Filter } from "effect/data"
*
* const isEven = (n: number) => Effect.succeed(n % 2 === 0)
* const isEven = (n: number) => Effect.succeed(n % 2 === 0 ? n : Filter.fail(n))
*
* const program = Effect.filter([1, 2, 3, 4, 5], isEven)
*
Expand Down Expand Up @@ -3787,14 +3788,15 @@ export const filter: <A, B, X, E, R>(
* @example
* ```ts
* import { Effect } from "effect"
* import { Filter } from "effect/data"
*
* // An effect that produces a number
* const program = Effect.succeed(5)
*
* // Filter for even numbers, provide alternative for odd numbers
* const filtered = Effect.filterOrElse(
* program,
* (n): n is number => n % 2 === 0,
* (n) => n % 2 === 0 ? n : Filter.fail(n),
* (n) => Effect.succeed(`Number ${n} is odd`)
* )
*
Expand Down Expand Up @@ -3828,14 +3830,15 @@ export const filterOrElse: {
* @example
* ```ts
* import { Effect } from "effect"
* import { Filter } from "effect/data"
*
* // An effect that produces a number
* const program = Effect.succeed(5)
*
* // Filter for even numbers, fail for odd numbers
* const filtered = Effect.filterOrFail(
* program,
* (n): n is number => n % 2 === 0,
* (n) => n % 2 === 0 ? n : Filter.fail(n),
* (n) => `Expected even number, got ${n}`
* )
*
Expand Down
Loading