Skip to main content

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

NameType
Textends 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

NameType
Textends 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

NameType
Textends readonly Option<any>[]

Parameters

NameTypeDescription
options[...T[]]An array of Options.

Returns

Option<UnwrapSomeArray<T>>

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

NameType
Textends readonly Option<any>[]

Parameters

NameTypeDescription
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.

Typeparam

T The result's type.

Type parameters

Name
T

Parameters

NameType
opResolvable<T> | () => Resolvable<T>

Returns

Option<T>

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.

Typeparam

T The result's type.

Type parameters

Name
T

Parameters

NameType
opAwaitable<Resolvable<T>> | () => Awaitable<Resolvable<T>>

Returns

Promise<Option<T>>

Defined in

projects/utilities/packages/result/src/lib/Option.ts:47


is

is<T>(value): true

Type parameters

Name
T

Parameters

NameType
valueOption<T>

Returns

true

Defined in

projects/utilities/packages/result/src/lib/Option.ts:23

is(value): value is Option<unknown>

Parameters

NameType
valueany

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

NameType
valueT

Returns

Some<T>

Defined in

projects/utilities/packages/result/src/lib/Option/Some.ts:186