Skip to main content

Class: Result<T, E>

Defined in: projects/shapeshift/src/lib/Result.ts:1

Type Parameters

Type ParameterDefault type
T-
E extends ErrorError

Properties

error?

readonly optional error: E

Defined in: projects/shapeshift/src/lib/Result.ts:4


success

readonly success: boolean

Defined in: projects/shapeshift/src/lib/Result.ts:2


value?

readonly optional value: T

Defined in: projects/shapeshift/src/lib/Result.ts:3

Methods

isErr()

isErr(): this is { error: E; success: false }

Defined in: projects/shapeshift/src/lib/Result.ts:19

Returns

this is { error: E; success: false }


isOk()

isOk(): this is { success: true; value: T }

Defined in: projects/shapeshift/src/lib/Result.ts:15

Returns

this is { success: true; value: T }


unwrap()

unwrap(): T

Defined in: projects/shapeshift/src/lib/Result.ts:23

Returns

T


err()

static err<T, E>(error: E): Result<T, E>

Defined in: projects/shapeshift/src/lib/Result.ts:32

Type Parameters

Type ParameterDefault type
T-
E extends ErrorError

Parameters

ParameterType
errorE

Returns

Result<T, E>


ok()

static ok<T, E>(value: T): Result<T, E>

Defined in: projects/shapeshift/src/lib/Result.ts:28

Type Parameters

Type ParameterDefault type
T-
E extends ErrorError

Parameters

ParameterType
valueT

Returns

Result<T, E>