W3cubDocs

/Babel

Syntax async functions

Syntax only

This plugin only allows Babel to parse this syntax. If you want to transform it then see transform-regenerator, transform-async-to-generator, or transform-async-to-module-method.

Example

Syntax

(async function() {
  await loadStory();
  console.log("Yey, story successfully loaded!");
}());

Installation

npm install --save-dev babel-plugin-syntax-async-functions

Usage

.babelrc

{
  "plugins": ["syntax-async-functions"]
}

Via CLI

babel --plugins syntax-async-functions script.js

Via Node API

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

References

© 2018 Sebastian McKenzie
Licensed under the MIT License.
http://babeljs.io/docs/plugins/syntax-async-functions/