콘텐츠로 이동

Result

Result: object

Defined in: packages/core/src/result.ts:13

Result utility functions for chaining and transformation

flatMap<T, U, E>(result, fn): Result<U, E>

Chain Result-returning operations

T

U

E

Result<T, E>

(value) => Result<U, E>

Result<U, E>

fromPromise<T, E>(promise): Promise<Result<T, E>>

Convert a Promise to a Result

T

E = Error

Promise<T>

Promise<Result<T, E>>

isFail<T, E>(result): result is Fail<E>

Check if a Result is Fail

T

E

Result<T, E>

result is Fail<E>

isOk<T, E>(result): result is Ok<T>

Check if a Result is Ok

T

E

Result<T, E>

result is Ok<T>

map<T, U, E>(result, fn): Result<U, E>

Transform the success value of a Result

T

U

E

Result<T, E>

(value) => U

Result<U, E>

mapError<T, E, F>(result, fn): Result<T, F>

Transform the error of a Result

T

E

F

Result<T, E>

(error) => F

Result<T, F>

match<T, E, U>(result, handlers): U

Pattern match on a Result

T

E

U

Result<T, E>

(error) => U

(value) => U

U

unwrap<T, E>(result): T

Extract the value or throw the error

T

E

Result<T, E>

T

unwrapOr<T, E>(result, defaultValue): T

Extract the value or return a default

T

E

Result<T, E>

T

T

unwrapOrElse<T, E>(result, fn): T

Extract the value or compute a default from the error

T

E

Result<T, E>

(error) => T

T