JSPM

  • Created
  • Published
  • Downloads 153179
  • Score
    100M100P100Q157272F
  • License BSD

Desugaring transpiler for ES6 generator functions

Package Exports

  • regenerator
  • regenerator/package.json
  • regenerator/runtime/dev
  • regenerator/runtime/dev.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (regenerator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

regenerator

This package implements a fully-functional source transformation that takes the proposed syntax for generators/yield from future versions of JS (ECMAScript6 or ES6, experimentally implemented in Node.js v0.11) and spits out efficient JS-of-today (ES5) that behaves the same way.

A small runtime library (664 bytes uglified and gzipped) is required to provide the wrapGenerator function. You can install it either as a CommonJS module or as a standalone .js file, whichever you prefer.

Installation

From NPM:

npm install regenerator

From GitHub:

cd path/to/node_modules
git clone git://github.com/benjamn/regenerator.git
cd regenerator
npm install .
npm test

Usage

You have several options for using this module.

Simplest usage:

path/to/node_modules/regenerator/bin/regenerate es6.js > es5.js

Programmatic usage:

var es5Source = require("regenerator")(es6Source);

AST transformation:

var recast = require("recast");
var ast = recast.parse(es6Source);
ast = require("regenerator").transform(ast);
var es5Source = recast.print(ast);

How can you get involved?

Fork the repository, create some failing tests cases, and send me pull requests. If you're feeling brave, you are more than welcome to dive into the transformer code and fix the bug(s) yourself.