generatorify

1.1.2 • Public • Published

Build Status npm version

Generatorify

Name is a bit misleading, this package wrap a function with callback into native ES6 promise so it can be used with generators. Module is based on this gist.

Prerequests

This library works with io.js or node.js with --harmony flag. It requires native Promises and Generators.

Usage


'use strict'

const request      = require('request')
const generatorify = require('generatorify')

const requestGenerator = generatorify(request)

const load = function* () {
  let result = yield requestGenerator('http://www.google.com')

  ...
}

Test

tap test/*.js

Limitations

As mentioned above, this module requires io.js or node.js with --harmony flag. Also it works only with functions with one callback, if you have more than one, only one will be converted.

/generatorify/

    Package Sidebar

    Install

    npm i generatorify

    Weekly Downloads

    2

    Version

    1.1.2

    License

    MIT

    Last publish

    Collaborators

    • slobodan