@esfx/async-deferred Package
The @esfx/async-deferred
package provides the Deferred class, an async coordination primitive.
Installation
npm i @esfx/async-deferred
Usage
import { Deferred } from "@esfx/async-deferred";
const deferred = new Deferred<number>();
// to resolve the deferred:
deferred.resolve(1);
// to reject the deferred:
deferred.reject(new Error());
// get the promise for the deferred:
deferred.promise;
Classes
Deferred
Encapsulates a Promise and exposes its resolve and reject callbacks.