1.0.0 • Published 1 year ago
resable-promise v1.0.0
Resable promise
Simple promise subclass, allowing for resolvement outside of callback (as property).
Installation
$ npm i resable-promise
Usage
Do this:
import ResablePromise from "resable-promise"
const prom = new ResablePromise()
// later...
prom.res()
So you dont have to do this:
let promRes
const prom = new Promise(res => promRes = res)
// later ...
promRes()
Only convinience, 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.
const prom = new ResablePromise()
prom.settled.then(() => console.log("settled"))
Contribute
All feedback is appreciated. Create a pull request or write an issue.