tiny-future • Docs
tiny-future / Future
A tiny way to make Promise
more convenient to use without any dependencies.
Create a new Future which wraps a new Promise
.
const future = new Future<number>();
asyncFunc(() => {
future.resolve(0);
});
return future.promise;
Type Parameter |
---|
T |
new Future<T>(): Future<T>
Future
<T
>
Property | Modifier | Type | Description | Defined in |
---|---|---|---|---|
promise |
readonly |
Promise <T > |
The Promise created by the Future. | future.ts:31 |
reject |
readonly |
(reason ?: any ) => void |
Reject the created Promise. | future.ts:26 |
resolve |
readonly |
(value : T | PromiseLike <T >) => void |
Resolve the created Promise. | future.ts:21 |