managed-status-promise
v1.1.2
Published
Extended promise with status management
Downloads
8
Readme
Extended Promise
This library provides an extended Promise with status management
Usage
import { ExtendedPromise, PromiseStatus } from 'managed-status-promise';
/**
* @README the internal promise will always resolve
* for a rejecting promise you can use the ExtendedPromise itself since it implements `PromiseLike`
* Additionally, the extended promise class extends EventTarget and emits a `changed` event for status changes
*/
const promise = new ExtendedPromise((resolve, reject) => {
reject(new Error('Error'))
});
expect(promise.status).toBe(PromiseStatus.FAILED);