out-promise

0.0.3 • Public • Published

OutPromise

Promise that resolves/rejects externally

Install

npm install out-promise

Simple usage

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'

Constructor

new OutPromise()

No parameters required. The function that resolves or rejects will be called externally

Methods

OutPromise.prototype.resolve(value)

Returns this object that is resolved with the given value

OutPromise.prototype.reject(reason)

Returns this object that is rejected with the given reason.

OutPromise.prototype.catch(onRejected)

Same behaviour as Promise.prototype.catch(onRejected)

OutPromise.prototype.then(onFulfilled, onRejected)

Same behaviour as Promise.prototype.then(onFulfilled, onRejected)

OutPromise.prototype.finally(onFinally)

Same behaviour as Promise.prototype.finally(onFinally)

Package Sidebar

Install

npm i out-promise

Weekly Downloads

53

Version

0.0.3

License

MIT

Unpacked Size

4.66 kB

Total Files

6

Last publish

Collaborators

  • jose-nunez