Class: Result<T, E>
Defined in: projects/shapeshift/src/lib/Result.ts:1
Type Parameters
Type Parameter | Default type |
---|---|
T | - |
E extends Error | Error |
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 Parameter | Default type |
---|---|
T | - |
E extends Error | Error |
Parameters
Parameter | Type |
---|---|
error | E |
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 Parameter | Default type |
---|---|
T | - |
E extends Error | Error |
Parameters
Parameter | Type |
---|---|
value | T |
Returns
Result
<T
, E
>