then2

0.0.1 • Public • Published

then2

Promise.then like callback generator.

Example

Before

function foo(callback) {
  async1((err, result1) => {
    if (err) {
      return callback(err);
    }
 
    async2((err, result2) => {
      if (err) {
        return callback(err);
      }
 
      callback(null, result1, result2);
    });
  });
}

After

import then from 'then2';
 
function foo(callback) {
  async1(then(
    result1 =>
      async2(then(
        result2 => {
        },
        callback
      )),
    callback
  ));
}

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i then2

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • nak2k