W3cubDocs

/Babel

Syntax async generators

Syntax only

This plugin only allows Babel to parse this syntax. If you want to transform it then see async-generator-functions and transform-regenerator if generator support is not supported natively.

Example

Syntax

async function* agf() {
  await 1;
}
async function f() {
  for await (let x of y) {
    g(x);
  }
}

Installation

npm install --save-dev babel-plugin-syntax-async-generators

Usage

.babelrc

{
  "plugins": ["syntax-async-generators"]
}

Via CLI

babel --plugins syntax-async-generators script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["syntax-async-generators"]
});

References

© 2018 Sebastian McKenzie
Licensed under the MIT License.
http://babeljs.io/docs/plugins/syntax-async-generators/