out-promise
Version:
Promise that resolves externally
53 lines (27 loc) • 1.08 kB
Markdown
Promise that resolves/rejects externally
`npm install out-promise`
```javascript
const OutPromise = require('out-promise')
let op = new OutPromise()
op.resolve('hi there')
op.then(resolved=>console.log(resolved)) // Will print 'hi there'
// You can also chain
new OutPromise().resolve('More greets').then(resolved=>console.log(resolved)) // Will print 'More greets'
```
No parameters required. The function that resolves or rejects will be called externally
Returns this object that is resolved with the given value
Returns this object that is rejected with the given reason.
Same behaviour as Promise.prototype.catch(onRejected)
Same behaviour as Promise.prototype.then(onFulfilled, onRejected)
Same behaviour as Promise.prototype.finally(onFinally)