Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

generatorify

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generatorify

Wrap function with callbacks to ES6 generator.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 23 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc