<A>(self: Option<A>): A | undefinedExtracts the value from a Some, or returns undefined for None.
When to use
Use when you need to pass absent Option values to APIs that expect
undefined.
Details
Some→ the inner valueNone→undefined
Example (Unwrapping to undefined)
import { Option } from "effect"
console.log(Option.getOrUndefined(Option.some(1)))
// Output: 1
console.log(Option.getOrUndefined(Option.none()))
// Output: undefinedSource effect/Option.ts:10091 lines
export const const getOrUndefined: <A>(
self: Option<A>
) => A | undefined
Extracts the value from a Some, or returns undefined for None.
When to use
Use when you need to pass absent Option values to APIs that expect
undefined.
Details
Some → the inner value
None → undefined
Example (Unwrapping to undefined)
import { Option } from "effect"
console.log(Option.getOrUndefined(Option.some(1)))
// Output: 1
console.log(Option.getOrUndefined(Option.none()))
// Output: undefined
getOrUndefined: <function (type parameter) A in <A>(self: Option<A>): A | undefinedA>(self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A>(self: Option<A>): A | undefinedA>) => function (type parameter) A in <A>(self: Option<A>): A | undefinedA | undefined = const getOrElse: {
<B>(onNone: LazyArg<B>): <A>(
self: Option<A>
) => B | A
<A, B>(self: Option<A>, onNone: LazyArg<B>):
| A
| B
}
getOrElse(import constUndefinedconstUndefined)Referenced by 5 symbols