Socket
Socket
Sign inDemoInstall

@babel/plugin-syntax-async-generators

Package Overview
Dependencies
81
Maintainers
5
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/plugin-syntax-async-generators

Allow parsing of async generator functions


Version published
Maintainers
5
Install size
10.5 kB
Created

Package description

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.

What are @babel/plugin-syntax-async-generators's main functionalities?

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++;
  }
}

Other packages similar to @babel/plugin-syntax-async-generators

Readme

Source

@babel/plugin-syntax-async-generators

Allow parsing of async generator functions.

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": ["@babel/plugin-syntax-async-generators"]
}

Via CLI

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

Via Node API

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

References

  • Proposal: Asynchronous iteration for ECMAScript

Keywords

FAQs

Last updated on 23 Apr 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc