generator-promise

1.0.0 • Public • Published

generator-promise

Adds promise() method to convert generators into promises. Behind the scenes this uses bluebird.coroutine.

Usage

Simply require this at the entry point of your app before any generator functions are defined

require('generator-promise');

And use it like so

function *getNote(id) {
    var note = yield db.Note.Get({ id: id });
    yield doSomethingElse();
    return note;
}

getNote(1234).promise().then(function(note) {
    console.log(note);
});

Readme

Keywords

none

Package Sidebar

Install

npm i generator-promise

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • crigney