@f/gen-to-promise

Convert generator to promise.

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/gen-to-promise
001.2.05 years ago6 years agoMinified + gzip package size for @f/gen-to-promise in KB

Readme

gen-to-promise

Build status Git tag NPM version Code style

Convert generator to promise.

Installation

$ npm install @f/gen-to-promise

Usage

var genToPromise = require('@f/gen-to-promise')

genToPromise(function * () {
  var students = yield fetch('/students').then((res) => res.json())
  var studentIds = students.map((student) => student.id)
  var teachers = yield fetch('/teachers.of', {body: {students: studentIds}}).then((res) => res.json())
  return teachers
}).then(function (teachers) {
  // teachers of students
})

API

genToPromise(gen)

  • gen - generator

Returns: a promise with all the "yieldeds" in gen resolved

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.