Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liammartens/extended-promise
https://github.com/liammartens/extended-promise
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/liammartens/extended-promise
- Owner: LiamMartens
- License: gpl-3.0
- Created: 2023-08-18T16:12:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-18T17:50:47.000Z (over 1 year ago)
- Last Synced: 2024-12-08T14:04:42.418Z (21 days ago)
- Language: TypeScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Extended Promise
This library provides an extended Promise with status management
## Usage
```js
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);
```