What is @babel/plugin-syntax-async-generators?
The @babel/plugin-syntax-async-generators package allows Babel to parse code that uses async generator functions. These are functions that can pause execution and resume asynchronously, making them useful for handling streams of data or other asynchronous operations in a more readable way than using Promises or callbacks alone.
Parsing async generator functions
This code defines an async generator function that yields numbers from 0 to 2. The @babel/plugin-syntax-async-generators package allows Babel to understand and parse this syntax.
async function* asyncGenerator() {
var i = 0;
while (i < 3) {
yield i++;
}
}