poor-man-promise

1.0.2 • Public • Published

Poor Man's Promise Implementation

Install

npm install poor-man-promise

Use

var Promise = require('poor-man-promise');

new Promise(function(accept) {
  setTimeout(function() {
    accept(1);
  }, 1000);
})
.then(function(value) {
  return value * 2;
})
.then(function(value) {
  return new Promise(function(accept) {
    setTimeout(function() {
      accept(value + 5);
    }, 1000);
  });
})
.then(function(finalAnswer) {
  console.log('The final answer is ' + finalAnswer);
});

The above prints:

The final answer is 7

Known Issues

Doesn't not support rejections yet.

Readme

Keywords

none

Package Sidebar

Install

npm i poor-man-promise

Weekly Downloads

0

Version

1.0.2

License

ISC

Last publish

Collaborators

  • airportyh