Refactor move docs (#8108)

* feat: [skip] generate readme script

* docs: [skip ci] update READMEs

* docs: [skip ci] fix code block type

* chore: [skip ci] move generator script
This commit is contained in:
Sven SAULEAU
2018-06-04 16:32:39 +02:00
committed by Henry Zhu
parent b6eaaa2496
commit b445b79734
143 changed files with 1286 additions and 11238 deletions

View File

@@ -2,88 +2,18 @@
> Turn async functions into ES2015 generators
> In Babel 7, `transform-async-to-module-method` was merged into this plugin
See our website [@babel/plugin-transform-async-to-generator](https://new.babeljs.io/docs/en/next/babel-plugin-transform-async-to-generator.html) for more information.
## Example
## Install
**In**
```javascript
async function foo() {
await bar();
}
```
**Out**
```javascript
var _asyncToGenerator = function (fn) {
...
};
var foo = _asyncToGenerator(function* () {
yield bar();
});
```
**Out with options**
> Turn async functions into a Bluebird coroutine
```javascript
var Bluebird = require("bluebird");
var foo = Bluebird.coroutine(function* () {
yield bar();
});
```
## Installation
Using npm:
```sh
npm install --save-dev @babel/plugin-transform-async-to-generator
npm install --save @babel/plugin-transform-async-to-generator
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
Without options:
```json
{
"plugins": ["@babel/plugin-transform-async-to-generator"]
}
```
With options:
```json
{
"plugins": [
["@babel/plugin-transform-async-to-generator", {
"module": "bluebird",
"method": "coroutine"
}]
]
}
```
### Via CLI
or using yarn:
```sh
babel --plugins @babel/plugin-transform-async-to-generator script.js
yarn add --save @babel/plugin-transform-async-to-generator
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-transform-async-to-generator"]
});
```
## References
* [Proposal: Async Functions for ECMAScript](https://github.com/tc39/ecmascript-asyncawait)