Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@babel/plugin-transform-async-to-generator
Advanced tools
Package description
The @babel/plugin-transform-async-to-generator package is a Babel plugin that transforms async functions into generator functions using the regenerator runtime, which is a part of the Facebook Regenerator project. This transformation allows async functions to be used in environments that do not natively support async/await syntax by converting them into ES2015/ES6 compatible code.
Transform async functions to generators
This feature allows developers to write asynchronous code using the modern async/await syntax and have it transformed into generator functions that are compatible with older JavaScript engines.
async function foo() {
await bar();
}
// Transforms to:
function foo() {
return regeneratorRuntime.async(function foo$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return regeneratorRuntime.awrap(bar());
case 2:
case "end":
return _context.stop();
}
}
}, null, this);
}
This package is similar to @babel/plugin-transform-async-to-generator in that it transforms async functions, but it does so by delegating to a specified module method, allowing for custom handling of async functions.
Fast-async is a Babel plugin that uses nodent to transform async/await functions. It is designed to be faster than the regenerator-based approach used by @babel/plugin-transform-async-to-generator and does not require a runtime.
While not a direct alternative, babel-preset-env includes the capability to transform async functions when the target environments specified do not support them natively. It uses @babel/plugin-transform-async-to-generator as part of its transformation suite when necessary.
Changelog
v7.24.1 (2024-03-19)
babel-helper-create-class-features-plugin
, babel-plugin-proposal-decorators
babel-plugin-proposal-decorators
, babel-plugin-proposal-json-modules
, babel-plugin-transform-async-generator-functions
, babel-plugin-transform-regenerator
, babel-plugin-transform-runtime
, babel-preset-env
moduleName
for @babel/runtime/regenerator
imports (@nicolo-ribaudo)babel-helper-create-class-features-plugin
, babel-plugin-proposal-decorators
, babel-plugin-proposal-pipeline-operator
, babel-plugin-transform-class-properties
babel-helper-create-class-features-plugin
, babel-helper-replace-supers
, babel-plugin-proposal-decorators
, babel-plugin-transform-class-properties
babel-code-frame
, babel-highlight
chalk
with picocolors
(@nicolo-ribaudo)babel-helper-fixtures
, babel-helpers
, babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression
, babel-plugin-proposal-pipeline-operator
, babel-plugin-transform-unicode-sets-regex
, babel-preset-env
, babel-preset-flow
babel-helpers
, babel-plugin-transform-async-generator-functions
, babel-plugin-transform-class-properties
, babel-plugin-transform-class-static-block
, babel-plugin-transform-modules-commonjs
, babel-plugin-transform-modules-systemjs
, babel-plugin-transform-regenerator
, babel-plugin-transform-runtime
, babel-preset-env
, babel-runtime-corejs3
, babel-runtime
, babel-standalone
babel-helper-module-imports
, babel-plugin-proposal-import-wasm-source
, babel-plugin-proposal-json-modules
, babel-plugin-proposal-record-and-tuple
, babel-plugin-transform-react-jsx-development
, babel-plugin-transform-react-jsx
babel-helper-create-class-features-plugin
, babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression
, babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining
, babel-plugin-bugfix-v8-static-class-fields-redefine-readonly
, babel-plugin-external-helpers
, babel-plugin-proposal-async-do-expressions
, babel-plugin-proposal-decorators
, babel-plugin-proposal-destructuring-private
, babel-plugin-proposal-do-expressions
, babel-plugin-proposal-duplicate-named-capturing-groups-regex
, babel-plugin-proposal-explicit-resource-management
, babel-plugin-proposal-export-default-from
, babel-plugin-proposal-function-bind
, babel-plugin-proposal-function-sent
, babel-plugin-proposal-import-attributes-to-assertions
, babel-plugin-proposal-import-defer
, babel-plugin-proposal-import-wasm-source
, babel-plugin-proposal-json-modules
, babel-plugin-proposal-optional-chaining-assign
, babel-plugin-proposal-partial-application
, babel-plugin-proposal-pipeline-operator
, babel-plugin-proposal-record-and-tuple
, babel-plugin-proposal-regexp-modifiers
, babel-plugin-proposal-throw-expressions
, babel-plugin-syntax-async-do-expressions
, babel-plugin-syntax-decimal
, babel-plugin-syntax-decorators
, babel-plugin-syntax-destructuring-private
, babel-plugin-syntax-do-expressions
, babel-plugin-syntax-explicit-resource-management
, babel-plugin-syntax-export-default-from
, babel-plugin-syntax-flow
, babel-plugin-syntax-function-bind
, babel-plugin-syntax-function-sent
, babel-plugin-syntax-import-assertions
, babel-plugin-syntax-import-attributes
, babel-plugin-syntax-import-defer
, babel-plugin-syntax-import-reflection
, babel-plugin-syntax-import-source
, babel-plugin-syntax-jsx
, babel-plugin-syntax-module-blocks
, babel-plugin-syntax-optional-chaining-assign
, babel-plugin-syntax-partial-application
, babel-plugin-syntax-pipeline-operator
, babel-plugin-syntax-record-and-tuple
, babel-plugin-syntax-throw-expressions
, babel-plugin-syntax-typescript
, babel-plugin-transform-arrow-functions
, babel-plugin-transform-async-generator-functions
, babel-plugin-transform-async-to-generator
, babel-plugin-transform-block-scoped-functions
, babel-plugin-transform-block-scoping
, babel-plugin-transform-class-properties
, babel-plugin-transform-class-static-block
, babel-plugin-transform-classes
, babel-plugin-transform-computed-properties
, babel-plugin-transform-destructuring
, babel-plugin-transform-dotall-regex
, babel-plugin-transform-duplicate-keys
, babel-plugin-transform-dynamic-import
, babel-plugin-transform-exponentiation-operator
, babel-plugin-transform-export-namespace-from
, babel-plugin-transform-flow-comments
, babel-plugin-transform-flow-strip-types
, babel-plugin-transform-for-of
, babel-plugin-transform-function-name
, babel-plugin-transform-instanceof
, babel-plugin-transform-jscript
, babel-plugin-transform-json-strings
, babel-plugin-transform-literals
, babel-plugin-transform-logical-assignment-operators
, babel-plugin-transform-member-expression-literals
, babel-plugin-transform-modules-amd
, babel-plugin-transform-modules-commonjs
, babel-plugin-transform-modules-systemjs
, babel-plugin-transform-modules-umd
, babel-plugin-transform-new-target
, babel-plugin-transform-nullish-coalescing-operator
, babel-plugin-transform-numeric-separator
, babel-plugin-transform-object-assign
, babel-plugin-transform-object-rest-spread
, babel-plugin-transform-object-set-prototype-of-to-assign
, babel-plugin-transform-object-super
, babel-plugin-transform-optional-catch-binding
, babel-plugin-transform-optional-chaining
, babel-plugin-transform-parameters
, babel-plugin-transform-private-methods
, babel-plugin-transform-private-property-in-object
, babel-plugin-transform-property-literals
, babel-plugin-transform-property-mutators
, babel-plugin-transform-proto-to-assign
, babel-plugin-transform-react-constant-elements
, babel-plugin-transform-react-display-name
, babel-plugin-transform-react-inline-elements
, babel-plugin-transform-react-jsx-compat
, babel-plugin-transform-react-jsx-self
, babel-plugin-transform-react-jsx-source
, babel-plugin-transform-react-pure-annotations
, babel-plugin-transform-regenerator
, babel-plugin-transform-reserved-words
, babel-plugin-transform-runtime
, babel-plugin-transform-shorthand-properties
, babel-plugin-transform-spread
, babel-plugin-transform-sticky-regex
, babel-plugin-transform-strict-mode
, babel-plugin-transform-template-literals
, babel-plugin-transform-typeof-symbol
, babel-plugin-transform-typescript
, babel-plugin-transform-unicode-escapes
, babel-plugin-transform-unicode-property-regex
, babel-plugin-transform-unicode-regex
, babel-plugin-transform-unicode-sets-regex
, babel-preset-env
, babel-preset-flow
, babel-preset-react
, babel-preset-typescript
babel-compat-data
, babel-plugin-transform-object-rest-spread
, babel-preset-env
@babel/compat-data
package.json (@nicolo-ribaudo)babel-helper-replace-supers
, babel-plugin-transform-class-properties
, babel-plugin-transform-classes
, babel-plugin-transform-parameters
, babel-plugin-transform-runtime
assertThisInitialized
after super()
(@liuxingbaoyu)babel-plugin-transform-class-properties
, babel-plugin-transform-classes
assertThisInitialized
more often (@liuxingbaoyu)babel-plugin-proposal-decorators
, babel-plugin-transform-class-properties
, babel-plugin-transform-object-rest-spread
, babel-traverse
babel-core
, babel-plugin-external-helpers
, babel-plugin-proposal-decorators
, babel-plugin-proposal-function-bind
, babel-plugin-transform-class-properties
, babel-plugin-transform-classes
, babel-plugin-transform-flow-comments
, babel-plugin-transform-flow-strip-types
, babel-plugin-transform-function-name
, babel-plugin-transform-modules-systemjs
, babel-plugin-transform-parameters
, babel-plugin-transform-private-property-in-object
, babel-plugin-transform-react-jsx
, babel-plugin-transform-runtime
, babel-plugin-transform-spread
, babel-plugin-transform-typescript
, babel-preset-env
Readme
Turn async functions into ES2015 generators
See our website @babel/plugin-transform-async-to-generator for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-async-to-generator
or using yarn:
yarn add @babel/plugin-transform-async-to-generator --dev
FAQs
Turn async functions into ES2015 generators
The npm package @babel/plugin-transform-async-to-generator receives a total of 18,842,815 weekly downloads. As such, @babel/plugin-transform-async-to-generator popularity was classified as popular.
We found that @babel/plugin-transform-async-to-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.