tiny-future
Version:
A tiny way to make `Promise` more convenient to use without any dependencies.
33 lines (31 loc) • 756 B
TypeScript
/**
* A tiny way to make `Promise` more convenient to use without any dependencies.
*
* Create a new Future which wraps a new `Promise`.
*
* @example
* ```ts
* const future = new Future<number>();
* asyncFunc(() => {
* future.resolve(0);
* });
* return future.promise;
* ```
*/
declare class Future<T> {
/**
* Resolve the created Promise.
*/
readonly resolve: Parameters<ConstructorParameters<typeof Promise<T>>[0]>[0];
/**
* Reject the created Promise.
*/
readonly reject: Parameters<ConstructorParameters<typeof Promise<T>>[0]>[1];
/**
* The Promise created by the Future.
*/
readonly promise: Promise<T>;
constructor();
}
export { Future };
//# sourceMappingURL=types.d.ts.map