add-callback-to-promise
v1.0.2
Published
npm i --save add-callback-to-promise
Downloads
19
Readme
Install
npm i --save add-callback-to-promise
Use
Makes it easier to create a function which returns a Promise but also allows a user to specify a callback.
Example
const addCallbackToPromise = require('add-callback-to-promise')
function somethingLongrunning(options, callback /*optional*/)
let p = new Promise((resolve, reject) => {
// Some code here
if(err) {
return reject(err)
}
resolve(result)
})
return addCallbackToPromise(p, callback)
}