https://github.com/maximilianmairinger/resablepromise
Simple promise subclass, allowing for resolvement outside of callback (as property).
https://github.com/maximilianmairinger/resablepromise
able promise resable resolve utility
Last synced: over 1 year ago
JSON representation
Simple promise subclass, allowing for resolvement outside of callback (as property).
- Host: GitHub
- URL: https://github.com/maximilianmairinger/resablepromise
- Owner: maximilianMairinger
- Created: 2023-03-02T10:14:07.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-22T22:47:19.000Z (over 2 years ago)
- Last Synced: 2025-01-22T08:42:46.997Z (over 1 year ago)
- Topics: able, promise, resable, resolve, utility
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/resable-promise
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# DEPRECATED
Use analog implementation in [more-proms](https://npmjs.com/package/more-proms) instead.
# Resable promise
Simple promise subclass, allowing for resolvent outside of callback (as property).
## Installation
```shell
$ npm i resable-promise
```
## Usage
Do this:
```ts
import ResablePromise from "resable-promise"
const prom = new ResablePromise()
// later...
prom.res()
```
So you dont have to do this:
```ts
let promRes
const prom = new Promise(res => promRes = res)
// later ...
promRes()
```
Only convenience, as I see myself doing this a lot. And this provides type safety without effort.
### On Settled
Is a promise that resolves when the base promise is ether resolved or rejected.
```ts
const prom = new ResablePromise()
prom.settled.then(() => console.log("settled"))
```
## Contribute
All feedback is appreciated. Create a pull request or write an issue.