( defaultValue: Effect.Effect<T, SchemaIssue.Issue, R> )
| 660 | * @since 4.0.0 |
| 661 | */ |
| 662 | export function withDefault<T, R = never>( |
| 663 | defaultValue: Effect.Effect<T, SchemaIssue.Issue, R> |
| 664 | ): Getter<T, T | undefined, R> { |
| 665 | return new Getter((o) => { |
| 666 | const filtered = Option.filter(o, Predicate.isNotUndefined) |
| 667 | return Option.isSome(filtered) ? Effect.succeed(filtered) : Effect.mapEager(defaultValue, Option.some) |
| 668 | }) |
| 669 | } |
| 670 | |
| 671 | /** |
| 672 | * Coerces any value to a `string` using the global `String()` constructor. |