Skip to main content

@babel/plugin-syntax-async-generators

note

Syntax only

It's unlikely you want to use this plugin directly as it only enables Babel to parse this syntax. Instead, use plugin-proposal-async-generators to both parse and transform this syntax.

Example

Syntax

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

Installation

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

Usage

babel.config.json
{
"plugins": ["@babel/plugin-syntax-async-generators"]
}

Via CLI

Shell
babel --plugins @babel/plugin-syntax-async-generators script.js

Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-syntax-async-generators"]
});

References