future
Future<T> class: an enhanced promise capable of carrying Either values and exposing helpers like Future.all.
Interactive example
Syntax
typescript
function future<
GenericEither extends AnyValue
>(value: GenericEither): Future<GenericEither>;Parameters
input: Can be anEither, a promise, or any value.Futurenormalizes everything to return anEitherin an async context.
Return value
An instance of Future, subclass of Promise, whose await automatically returns an Either (FutureSuccess, FutureError, or any provided Either).
Best practices
Futureautomatically propagates the firstLeftencountered: combine it withE.rightAsyncPipefor your async pipelines.- Use
Future.all([...])to wait for multiple typed operations. - Prefer
futureSuccess/futureErrorto create base cases.
See also
futureSuccess.futureError.rightAsyncPipe– To chain async operations.
