Namespace: Option
@sapphire/result.Option
Type Aliases
None
Ƭ None: None
Defined in
projects/utilities/packages/result/src/lib/Option.ts:93
Resolvable
Ƭ Resolvable<T
>: T
| null
| undefined
| Option
<T
>
Type parameters
Name |
---|
T |
Defined in
projects/utilities/packages/result/src/lib/Option.ts:16
Some
Ƭ Some<T
>: Some
<T
>
Type parameters
Name |
---|
T |
Defined in
projects/utilities/packages/result/src/lib/Option.ts:92
UnwrapSome
Ƭ UnwrapSome<T
>: T
extends Some
<infer S> ? S
: never
Type parameters
Name | Type |
---|---|
T | extends Option <any > |
Defined in
projects/utilities/packages/result/src/lib/Option.ts:95
UnwrapSomeArray
Ƭ UnwrapSomeArray<T
>: { -readonly [P in keyof T]: UnwrapSome<T[P]> }
Type parameters
Name | Type |
---|---|
T | extends readonly Option <any >[] | [] |
Defined in
projects/utilities/packages/result/src/lib/Option.ts:96
Variables
none
• Const
none: None
= createNone
Defined in
projects/utilities/packages/result/src/lib/Option.ts:89
Functions
all
▸ all<T
>(options
): Option
<UnwrapSomeArray
<T
>>
Creates a Some that is the combination of all collected Some values as an array, or the first None encountered.
Type parameters
Name | Type |
---|---|
T | extends readonly Option <any >[] |
Parameters
Name | Type | Description |
---|---|---|
options | [...T[]] | An array of Options. |
Returns
A new Option.
Defined in
projects/utilities/packages/result/src/lib/Option.ts:61
any
▸ any<T
>(options
): Option
<UnwrapSomeArray
<T
>[number
]>
Returns the first encountered Some, or a None if none was found.
Type parameters
Name | Type |
---|---|
T | extends readonly Option <any >[] |
Parameters
Name | Type | Description |
---|---|---|
options | [...T[]] | An array of Options. |
Returns
Option
<UnwrapSomeArray
<T
>[number
]>
A new Option.
Defined in
projects/utilities/packages/result/src/lib/Option.ts:79
from
▸ from<T
>(op
): Option
<T
>
Creates an Option out of a value or callback.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
op | Resolvable <T > | () => Resolvable <T > |
Returns
Option
<T
>
Typeparam
T The result's type.
Defined in
projects/utilities/packages/result/src/lib/Option.ts:33
fromAsync
▸ fromAsync<T
>(op
): Promise
<Option
<T
>>
Creates an Option out of a value or callback.
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
op | Awaitable <Resolvable <T >> | () => Awaitable <Resolvable <T >> |
Returns
Typeparam
T The result's type.
Defined in
projects/utilities/packages/result/src/lib/Option.ts:47
is
▸ is<T
>(value
): true
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
value | Option <T > |
Returns
true
Defined in
projects/utilities/packages/result/src/lib/Option.ts:23
▸ is(value
): value is Option<unknown>
Parameters
Name | Type |
---|---|
value | any |
Returns
value is Option<unknown>
Defined in
projects/utilities/packages/result/src/lib/Option.ts:24
some
▸ some<T
>(value
): Some
<T
>
Type parameters
Name |
---|
T |
Parameters
Name | Type |
---|---|
value | T |
Returns
Some
<T
>