default
default:
object
Type Declarationβ
none: Noneβ
The None instance representing absence of value.
Sinceβ
2.0.0
some(): <A>(a) => Option<A>β
Creates a Some containing the given value.
Type Parametersβ
A: Aβ
The value type.
a:
Aβ The value to wrap.
Returns:Option<A>β A Some containing the value.
Sinceβ
2.0.0
of(): <A>(a) => Option<A>β
Alias for some.
Creates a Some containing the given value.
Type Parametersβ
A: Aβ
The value type.
a:
Aβ The value to wrap.
Returns:Option<A>β A Some containing the value.
Sinceβ
2.0.0
Sinceβ
2.0.0
isSome(): <A>(fa) => fa is Some<A>β
Type guard that checks if an Option is a Some.
Type Parametersβ
A: Aβ
The value type.
fa:
Option<A>β The Option to check.
Returns:fa is Some<A>β True if the Option is a Some.
Sinceβ
2.0.0
isNone(): (fa) => fa is Noneβ
Type guard that checks if an Option is a None.
fa:
Option<unknown>β The Option to check.
Returns:fa is Noneβ True if the Option is a None.
Sinceβ
2.0.0
fromNullable(): <A>(a) => Option<NonNullable<A>>β
Creates an Option from a nullable value.
Type Parametersβ
A: Aβ
The value type.
a:
Aβ The nullable value.
Returns:Option<NonNullable<A>>β Some if value is not null/undefined, None otherwise.
Sinceβ
2.0.0
fromPredicate(): {<A, B>(refinement): (a) => Option<B>; <A>(predicate): (a) => Option<A>; }β
Call Signature: > <A, B>(refinement): (a) => Option<B>β
Creates an Option from a predicate.
Type Parametersβ
A: Aβ
The value type.
B: Bβ
refinement:
(a) => a is Bβ The refinement or predicate function.
Returns:A function that creates an Option based on the predicate.β > (a):Option<B>
Returns:
Option<B>
Sinceβ
2.0.0
Call Signature: > <A>(predicate): (a) => Option<A>β
Creates an Option from a predicate.
Type Parametersβ
A: Aβ
The value type.
predicate:
(a) => boolean
Returns:A function that creates an Option based on the predicate.β > (a):Option<A>
Returns:
Option<A>
Sinceβ
2.0.0
map(): <A, B>(f) => (fa) => Option<B>β
Maps a function over the value of an Option.
Type Parametersβ
A: Aβ
The input type.
B: Bβ
The output type.
f:
(a) => Bβ The mapping function.
Returns:A function that transforms the Option.β > (fa):Option<B>
Sinceβ
2.0.0
flatMap(): <A, B>(f) => (ma) => Option<B>β
Chains a function that returns an Option over the value.
Type Parametersβ
A: Aβ
The input type.
B: Bβ
The output type.
f:
(a) => Option<B>β The chaining function.
Returns:A function that transforms the Option.β > (ma):Option<B>
Sinceβ
2.0.0
chain(): <A, B>(f) => (ma) => Option<B>β
Alias for flatMap.
Chains a function that returns an Option over the value.
Type Parametersβ
A: Aβ
The input type.
B: Bβ
The output type.
f:
(a) => Option<B>β The chaining function.
Returns:A function that transforms the Option.β > (ma):Option<B>
Sinceβ
2.0.0
Sinceβ
2.0.0
match(): <A, B>(onNone, onSome) => (ma) => Bβ
Pattern matches on an Option.
Type Parametersβ
A: Aβ
The value type.
B: Bβ
The return type.
onNone:
() => Bβ Handler for None case.
onSome:(a) => Bβ Handler for Some case.
Returns:A function that matches the Option.β > (ma):B
ma:
Option<A>
Returns:B
Sinceβ
2.0.0
fold(): <A, B>(onNone, onSome) => (ma) => Bβ
Alias for match.
Pattern matches on an Option.
Type Parametersβ
A: Aβ
The value type.
B: Bβ
The return type.
onNone:
() => Bβ Handler for None case.
onSome:(a) => Bβ Handler for Some case.
Returns:A function that matches the Option.β > (ma):B
ma:
Option<A>
Returns:B
Sinceβ
2.0.0
Sinceβ
2.0.0
matchW(): <B, A, C>(onNone, onSome) => (ma) => B | Cβ
Pattern matches on an Option with widened return types.
Type Parametersβ
B: Bβ
The return type for None.
A: Aβ
The value type.
C: Cβ
The return type for Some.
onNone:
() => Bβ Handler for None case.
onSome:(a) => Cβ Handler for Some case.
Returns:A function that matches the Option.β > (ma):B|C
ma:
Option<A>
Returns:B | C
Sinceβ
2.0.0
foldW(): <B, A, C>(onNone, onSome) => (ma) => B | Cβ
Alias for matchW.
Pattern matches on an Option with widened return types.
Type Parametersβ
B: Bβ
The return type for None.
A: Aβ
The value type.
C: Cβ
The return type for Some.
onNone:
() => Bβ Handler for None case.
onSome:(a) => Cβ Handler for Some case.
Returns:A function that matches the Option.β > (ma):B|C
ma:
Option<A>
Returns:B | C
Sinceβ
2.0.0
Sinceβ
2.0.0
getOrElse(): <A>(onNone) => (ma) => Aβ
Extracts the value from a Some or returns a default.
Type Parametersβ
A: Aβ
The value type.
onNone:
() => Aβ Function to provide default value.
Returns:A function that extracts the value.β > (ma):A
ma:
Option<A>
Returns:A
Sinceβ
2.0.0
getOrElseW(): <B>(onNone) => <A>(ma) => B | Aβ
Extracts the value from a Some or returns a default with widened type.
Type Parametersβ
B: Bβ
The default type.
onNone:
() => Bβ Function to provide default value.
Returns:A function that extracts the value.β > <A>(ma):B|A
Type Parametersβ
A: Aβ
ma:
Option<A>
Returns:B | A
Sinceβ
2.0.0
alt(): <A>(that) => (fa) => Option<A>β
Returns an alternative Option if the first is None.
Type Parametersβ
A: Aβ
The value type.
that:
() => Option<A>β Function to provide alternative Option.
Returns:A function that returns the alternative.β > (fa):Option<A>
Sinceβ
2.0.0
orElse(): <A>(that) => (fa) => Option<A>β
Alias for alt.
Returns an alternative Option if the first is None.
Type Parametersβ
A: Aβ
The value type.
that:
() => Option<A>β Function to provide alternative Option.
Returns:A function that returns the alternative.β > (fa):Option<A>
Sinceβ
2.0.0
Sinceβ
2.0.0
filter(): <A>(predicate) => (fa) => Option<A>β
Filters the value with a predicate.
Type Parametersβ
A: Aβ
The value type.
predicate:
(a) => booleanβ The predicate function.
Returns:A function that filters the Option.β > (fa):Option<A>
Sinceβ
2.0.0
filterMap(): <A, B>(f) => (fa) => Option<B>β
Maps and filters in one operation.
Type Parametersβ
A: Aβ
The input type.
B: Bβ
The output type.
f:
(a) => Option<B>β The mapping function that returns an Option.
Returns:A function that filterMaps the Option.β > (fa):Option<B>
Sinceβ
2.0.0
toNullable(): <A>(ma) => A | nullβ
Converts an Option to a nullable value.
Type Parametersβ
A: Aβ
The value type.
ma:
Option<A>β The Option to convert.
Returns:A | nullβ The value or null.
Sinceβ
2.0.0
toUndefined(): <A>(ma) => A | undefinedβ
Converts an Option to an undefined value.
Type Parametersβ
A: Aβ
The value type.
ma:
Option<A>β The Option to convert.
Returns:A | undefinedβ The value or undefined.
Sinceβ
2.0.0
fromEither(): <A>(fa) => Option<A>β
Creates an Option from an Either.
Type Parametersβ
A: Aβ
The value type.
fa:
The Either to convert.β #
_tag:"Left" | "Right"β #
left?:unknownβ #
right?:A
Returns:Option<A>β Some if Right, None if Left.
Sinceβ
2.0.0
toEither(): <E>(onNone) => <A>(fa) => objectβ
Converts an Option to an Either.
Type Parametersβ
E: Eβ
The error type.
onNone:
() => Eβ Function to create error for None.
Returns:A function that converts the Option.β > <A>(fa):object
Type Parametersβ
A: Aβ
fa:
Option<A>
Returns:object
_tag: > *\_tag*: "Left" | "Right"β
left?: Eβ
right?: Aβ
Sinceβ
2.0.0
exists(): <A>(predicate) => (ma) => booleanβ
Tests if a predicate holds for the value.
Type Parametersβ
A: Aβ
The value type.
predicate:
(a) => booleanβ The predicate to test.
Returns:A function that tests the Option.β > (ma):boolean
ma:
Option<A>
Returns:boolean
Sinceβ
2.0.0
flatten(): <A>(mma) => Option<A>β
Flattens a nested Option.
Type Parametersβ
A: Aβ
The value type.
mma:
Option<Option<A>>β The nested Option.
Returns:Option<A>β The flattened Option.
Sinceβ
2.0.0
compact(): <A>(mma) => Option<A>β
Alias for flatten.
Flattens a nested Option.
Type Parametersβ
A: Aβ
The value type.
mma:
Option<Option<A>>β The nested Option.
Returns:Option<A>β The flattened Option.
Sinceβ
2.0.0
Sinceβ
2.0.0
apFirst(): (fb) => <A>(fa) => Option<A>β
Sequences two Options, keeping the first value.
fb:
Option<unknown>β The second Option.
Returns:A function that sequences the Options.β > <A>(fa):Option<A>
Type Parametersβ
A: Aβ
Sinceβ
2.0.0
apSecond(): <A>(fb) => <B>(fa) => Option<A>β
Sequences two Options, keeping the second value.
Type Parametersβ
A: Aβ
The value type.
fb:
Option<A>β The second Option.
Returns:A function that sequences the Options.β > <B>(fa):Option<A>
Type Parametersβ
B: Bβ
Sinceβ
2.0.0
flap(): <A>(a) => <B>(fab) => Option<B>β
Applies a value to a function inside an Option.
Type Parametersβ
A: Aβ
The input type.
a:
Aβ The value to apply.
Returns:A function that applies the value.β > <B>(fab):Option<B>
Type Parametersβ
B: Bβ
Sinceβ
2.0.0
as(): <A>(a) => <_>(self) => Option<A>β
Replaces the value with a constant.
Type Parametersβ
A: Aβ
The new value type.
a:
Aβ The constant value.
Returns:A function that replaces the value.β > <_>(self):Option<A>
Type Parametersβ
_: _β
Sinceβ
2.0.0
asUnit(): <_>(self) => Option<void>β
Replaces the value with void.
Type Parametersβ
_: _β
self:
Option<_>β The Option to transform.
Returns:Option<void>β An Option containing void.
Sinceβ
2.0.0
tryCatch(): <A>(f) => Option<A>β
Creates an Option by executing a function that may throw.
Type Parametersβ
A: Aβ
The value type.
f:
() => Aβ The function to execute.
Returns:Option<A>β Some if successful, None if throws.
Sinceβ
2.0.0
tryCatchK(): <A, B>(f) => (...a) => Option<B>β
Lifts a function to return an Option when called.
Type Parametersβ
A: A extends readonly unknown[]β
The argument types.
B: Bβ
The return type.
f:
(...a) => Bβ The function to lift.
Returns:A lifted function that returns an Option.β > (...a):Option<B>
a:
...A
Returns:Option<B>
Sinceβ
2.0.0
fromNullableK(): <A, B>(f) => (...a) => Option<NonNullable<B>>β
Lifts a function that may return null/undefined to return an Option.
Type Parametersβ
A: A extends readonly unknown[]β
The argument types.
B: Bβ
The return type.
f:
(...a) => Nullish<B>β The function to lift.
Returns:A lifted function that returns an Option.β > (...a):Option<NonNullable<B>>
a:
...A
Returns:Option<NonNullable<B>>
Sinceβ
2.0.0
chainNullableK(): <A, B>(f) => (ma) => Option<NonNullable<B>>β
Chains a function that may return null/undefined.
Type Parametersβ
A: Aβ
The input type.
B: Bβ
The output type.
f:
(a) => Nullish<B>β The chaining function.
Returns:A function that chains the Option.β > (ma):Option<NonNullable<B>>
Sinceβ
2.0.0