Skip to content

Latest commit

 

History

History
62 lines (45 loc) · 961 Bytes

plugin-transform-async-to-generator.md

File metadata and controls

62 lines (45 loc) · 961 Bytes
id title sidebar_label original_id
version-6.26.3-babel-plugin-transform-async-to-generator
babel-plugin-transform-async-to-generator
transform-async-to-generator
babel-plugin-transform-async-to-generator

Example

In

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

Out

var _asyncToGenerator = function (fn) {
  ...
};
var foo = _asyncToGenerator(function* () {
  yield bar();
});

Installation

npm install --save-dev babel-plugin-transform-async-to-generator

Usage

With a configuration file (Recommended)

{
  "plugins": ["transform-async-to-generator"]
}

Via CLI

babel --plugins transform-async-to-generator script.js

Via Node API

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

References