node-guarantee

1.0.3 • Public • Published

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

GNU

"Simplicity is the ultimate sophistication"
Da Vinci

Readme

Keywords

Package Sidebar

Install

npm i node-guarantee

Weekly Downloads

0

Version

1.0.3

License

ISC

Unpacked Size

37.3 kB

Total Files

5

Last publish

Collaborators

  • webarthur