Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-async-to-generator

Package Overview
Dependencies
Maintainers
6
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-async-to-generator

Turn async functions into ES2015 generators

  • 6.24.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
6
Created

What is babel-plugin-transform-async-to-generator?

The babel-plugin-transform-async-to-generator package is a Babel plugin that transforms async functions into ES2015 generator functions. This allows for the use of async/await syntax in environments that do not natively support it by converting the code into a form that can be executed by older JavaScript engines.

What are babel-plugin-transform-async-to-generator's main functionalities?

Transform async functions to generator functions

This feature allows you to transform an async function into a generator function. The provided code sample demonstrates how to use the Babel core library along with the babel-plugin-transform-async-to-generator plugin to transform an async function into a generator function.

const babel = require('@babel/core');
const code = `async function fetchData() { await fetch('https://api.example.com/data'); }`;
const output = babel.transform(code, { plugins: ['babel-plugin-transform-async-to-generator'] });
console.log(output.code);

Support for await expressions

This feature ensures that await expressions within async functions are properly transformed into yield expressions within generator functions. The code sample shows how an async function with an await expression is transformed.

const babel = require('@babel/core');
const code = `async function fetchData() { const data = await fetch('https://api.example.com/data'); return data; }`;
const output = babel.transform(code, { plugins: ['babel-plugin-transform-async-to-generator'] });
console.log(output.code);

Other packages similar to babel-plugin-transform-async-to-generator

Keywords

FAQs

Package last updated on 07 Apr 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc