Skip to content

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 an Either, a promise, or any value. Future normalizes everything to return an Either in 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 ​

  • Use Future.all([...]) to wait for multiple typed operations.
  • Prefer futureSuccess / futureError to create base cases.

See also ​

Released under the MIT license.