Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/gauntlet/imports/tmonad.ts>Future

Work-in-progress front-end tool which does put a smile on my face
Latest
class Future
import { Future } from "https://deno.land/x/gauntlet@v0.0.9/imports/tmonad.ts";

Future

Constructors

new
Future(promise: Promise<T>)

Properties

protected
_executor: () => Promise<Result<T, Error>>

Executor

protected
_promise: Promise<T>

Promise

Methods

extract(): Promise<T>

Get the value from the future (can throw)

flatMap<U>(f: (val: T) => Future<U>): Future<U>

Flatmap

flatMapErr<U>(f: (err: Error) => Future<U>): Future<U | T>

Flatmap on failure

flatMatch<U>(matchObject: FlatMatch<T, U>): Future<U>

FlatMatch

getOrElse<R>(defaultValue: R): Promise<T | R>

Get the value from the future, but if it's a failure, return the defaultValue

isFailure(): Promise<boolean>

Is a failure

isSuccess(): Promise<boolean>

Is a success

map<U>(f: (val: T) => Promise<U>): Future<U>

Map

mapErr<U>(f: (err: any) => Promise<U>): Future<U | T>

Map on error

match<U>(matchObject: Match<T, U>): Future<U>

Match

run<U>(gen: Generator<Promise<T> | undefined, Promise<U>, T>): Future<U>

Run a series of futures into a generator

toOption(): Promise<Option<T>>

Transform into Option

toResult(): Promise<Result<T, Error>>

Transform into Result