Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as mod from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/async_either.ts";

The AsyncEither datastructure represents an asynchronous operation that can fail. At its heart it is implemented as () => Promise<Either<B, A>>. This thunk makes it a performant but lazy operation at the expense of stack safety.

§Variables

ApplicableAsyncEither
BimappableAsyncEither
bind
bindTo
FailableAsyncEitherParallel
FailableAsyncEitherSequential
FlatmappableAsyncEitherParallel
FlatmappableAsyncEitherSequential
MappableAsyncEither
tap
WrappableAsyncEither

§Functions

alt

Provide an alternative for a failed computation. Useful for implementing defaults.

apply

Apply a function wrapped in an AsyncEither to a value wrapped in an AsyncEither.

applySequential

Apply a function wrapped in an AsyncEither to a value wrapped in an AsyncEither, sequentially.

fail

Construct an AsyncEither<B, A> from a value B.

flatmap

Chain AsyncEither computations together.

flatmapFirst

Chain AsyncEither computations together, but keep the original value if the chain fails.

fromAsync

Convert an Async to an AsyncEither, treating any failure as a Left.

fromEither

Convert an Either to an AsyncEither.

getCombinableAsyncEither

Create a Combinable instance for AsyncEither given Combinable instances for the Left and Right types.

getInitializableAsyncEither

Create an Initializable instance for AsyncEither given Initializable instances for the Left and Right types.

left

Constructs a AsyncEither from a value and wraps it in an inner Left traditionally signaling a failure.

map

Apply a function to the Right value of an AsyncEither.

mapSecond

Apply a function to the Left value of an AsyncEither.

match

Pattern match on an AsyncEither to extract the value.

recover

Chain AsyncEither based failures, Left sides, useful for recovering from error conditions.

right

Constructs a AsyncEither from a value and wraps it in an inner Right traditionally signaling a successful computation.

tryCatch

Wraps a Async of A in a try-catch block which upon failure returns B instead. Upon success returns a Right and Left for a failure.

wrap

Construct an AsyncEither<B, A> from a value A.

§Interfaces

KindAsyncEither

Specifies AsyncEither as a Higher Kinded Type, with covariant parameter A corresponding to the 0th index of any substitutions and covariant parameter B corresponding to the 1st index of any substitutions.

§Type Aliases

AsyncEither

The AsyncEither type can best be thought of as an asynchronous function that returns an Either. ie. async () => Promise<Either<B, A>>. This forms the basis of most Promise based asynchronous communication in TypeScript.