Skip to content

Success

Defined in: src/util/Try.ts:31

The computation returned a value.

T = unknown

new Success<T>(value): Success<T>

Defined in: src/util/Try.ts:33

T

Success<T>

readonly _tag: "Success"

Defined in: src/util/Try.ts:32


readonly value: T

Defined in: src/util/Try.ts:33

filter(pred, makeError?): Try<T>

Defined in: src/util/Try.ts:63

Keep if predicate holds; else Failure with a FilterError.

(value) => boolean

(value) => Error

Try<T>


flatMap<U>(f): Try<U>

Defined in: src/util/Try.ts:51

Chain to another Try. A thrown mapper becomes Failure.

U

(value) => Try<U>

Try<U>


fold<U>(_onFailure, onSuccess): U

Defined in: src/util/Try.ts:72

Collapse both cases into one value.

U

(err) => U

(value) => U

U


forEach(f): void

Defined in: src/util/Try.ts:77

Run a side-effect on the value.

(value) => void

void


get(): T

Defined in: src/util/Try.ts:80

Convert to a “classic” value — the inner value.

T


getOrElse<U>(_fallback): T

Defined in: src/util/Try.ts:39

Always Success; fallback ignored.

U

U | ((err) => U)

T


isFailure(): this is Failure

Defined in: src/util/Try.ts:36

this is Failure


isSuccess(): this is Success<T>

Defined in: src/util/Try.ts:35

this is Success<T>


map<U>(f): Try<U>

Defined in: src/util/Try.ts:45

Map the inner value. A thrown mapper turns this into a Failure.

U

(value) => U

Try<U>


orElse<U>(_alt): Try<T>

Defined in: src/util/Try.ts:42

Always Success; alternative ignored.

U

Try<U> | (() => Try<U>)

Try<T>


recover<U>(_f): Try<T | U>

Defined in: src/util/Try.ts:57

Always Success — no recovery runs.

U

(err) => U | null

Try<T | U>


recoverWith<U>(_f): Try<T | U>

Defined in: src/util/Try.ts:60

Always Success — no recovery runs.

U

(err) => Try<U>

Try<T | U>


toError(): Error | null

Defined in: src/util/Try.ts:86

Fresh copy of the error, or null.

Error | null


toNullable(): T | null

Defined in: src/util/Try.ts:83

Convert to an Option-like shape (null on Failure).

T | null