node-guarantee
v1.0.3
Published
Promises without the new constructor keyword
Downloads
3
Readme
Guarantee.js
Promises without the new constructor keyword.
const Guarantee = require('Guarantee')
function doSomething () {
const promise = Guarantee()
setTimeout(function () {
promise.resolve('Yeah!')
}, 1000)
return promise
}
doSomething()
.then(function (data) {
console.log(data)
})
You can also use the Promise.new() function:
require('Guarantee')
function doSomething () {
const promise = Promise.new()
setTimeout(function () {
promise.resolve('Yeah!')
}, 1000)
return promise
}
doSomething()
.then(function (data) {
console.log(data)
})
This package adds the "new function" to Promise proto so you can use Promise.new() instead the Guarantee() standard function.
License
"Simplicity is the ultimate sophistication" Da Vinci