1. babel-plugin-transform-async-to-module-method
Turn async functions into a module method
babel-plugin-transform-async-to-module-method
Package: babel-plugin-transform-async-to-module-method
Created by: babel
Last modified: Mon, 13 Jun 2022 04:04:02 GMT
Version: 6.24.1
License: MIT
Downloads: 8,736
Repository: https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-async-to-module-method

Install

npm install babel-plugin-transform-async-to-module-method
yarn add babel-plugin-transform-async-to-module-method

babel-plugin-transform-async-to-module-method

Turn async functions into a Bluebird coroutine

Example

In

 async function foo() {
  await bar();
}

Out

 var Bluebird = require("bluebird");

var foo = Bluebird.coroutine(function* () {
  yield bar();
});

Installation

 npm install --save-dev babel-plugin-transform-async-to-module-method

Usage

Via .babelrc (Recommended)

.babelrc

Without options:

 {
  "plugins": ["transform-async-to-module-method"]
}

With options:

 {
  "plugins": [
    ["transform-async-to-module-method", {
      "module": "bluebird",
      "method": "coroutine"
    }]
  ]
}

Via CLI

 babel --plugins transform-async-to-module-method script.js

Via Node API

 require("babel-core").transform("code", {
  plugins: ["transform-async-to-module-method"]
});

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code