@babel/plugin-transform-regenerator
Advanced tools
Comparing version 7.0.0-beta.49 to 7.0.0-beta.50
@@ -5,3 +5,3 @@ { | ||
"description": "Explode async and generator functions into a state machine.", | ||
"version": "7.0.0-beta.49", | ||
"version": "7.0.0-beta.50", | ||
"homepage": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-regenerator", | ||
@@ -11,3 +11,3 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-regenerator", | ||
"dependencies": { | ||
"regenerator-transform": "^0.12.3" | ||
"regenerator-transform": "^0.12.4" | ||
}, | ||
@@ -19,5 +19,5 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.49", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.49" | ||
"@babel/core": "7.0.0-beta.50", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.50" | ||
} | ||
} |
# @babel/plugin-transform-regenerator | ||
> Transform async/generator functions with [regenerator](https://github.com/facebook/regenerator) | ||
> Explode async and generator functions into a state machine. | ||
## Example | ||
See our website [@babel/plugin-transform-regenerator](https://new.babeljs.io/docs/en/next/babel-plugin-transform-regenerator.html) for more information. | ||
**In** | ||
## Install | ||
```javascript | ||
function* a() { | ||
yield 1; | ||
} | ||
``` | ||
Using npm: | ||
**Out** | ||
```javascript | ||
var _marked = [a].map(regeneratorRuntime.mark); | ||
function a() { | ||
return regeneratorRuntime.wrap(function a$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return 1; | ||
case 2: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _marked[0], this); | ||
} | ||
``` | ||
## Installation | ||
```sh | ||
npm install --save-dev @babel/plugin-transform-regenerator | ||
npm install --save @babel/plugin-transform-regenerator | ||
``` | ||
## Usage | ||
or using yarn: | ||
### Via `.babelrc` (Recommended) | ||
Without options: | ||
```json | ||
{ | ||
"plugins": ["@babel/plugin-transform-regenerator"] | ||
} | ||
``` | ||
With options: | ||
|name|default value| | ||
|---|---| | ||
|asyncGenerators|true| | ||
|generators|true| | ||
|async|true| | ||
```json | ||
{ | ||
"plugins": [ | ||
["@babel/plugin-transform-regenerator", { | ||
"asyncGenerators": false, | ||
"generators": false, | ||
"async": false | ||
}] | ||
] | ||
} | ||
``` | ||
### Via CLI | ||
```sh | ||
babel --plugins @babel/plugin-transform-regenerator script.js | ||
yarn add --save @babel/plugin-transform-regenerator | ||
``` | ||
### Via Node API | ||
```javascript | ||
require("@babel/core").transform("code", { | ||
plugins: ["@babel/plugin-transform-regenerator"] | ||
}); | ||
``` |
1640
3
20