Skip to content
Transform async/await to somewhat idiomatic JavaScript promise chains
TypeScript JavaScript
Branch: master
Clone or download
Latest commit b409b91 Oct 27, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests Minify return statements used to implement breaks inside tails Oct 26, 2019
.gitignore Package helpers in helpers-string.js as a commonjs module so that bun… Apr 20, 2019
.npmignore Add prettier and typescript configuration files to npm ignore Aug 4, 2019
.prettierrc.json Format code using prettier and check for formatting during CI builds Aug 4, 2019
.travis.yml Run against node 12 in CI Oct 26, 2019
LICENSE Update copyright date Aug 4, 2019 Simplify calls to known static methods Apr 1, 2019
async-to-promises.test.js Allow running only a subset of output tests, to make prototyping easier Oct 26, 2019
async-to-promises.ts Make more variables const/readonly Oct 26, 2019
generate-helpers-string.js Package helpers in helpers-string.js as a commonjs module so that bun… Apr 20, 2019
helpers-string.d.ts Package helpers in helpers-string.js as a commonjs module so that bun… Apr 20, 2019
helpers.js Fix for async iteration when the body contains a break statement (closes Oct 19, 2019
package.json Public Release 0.8.15 Oct 26, 2019
tsconfig.json Enable stricter TypeScript checking and cleanup new errors Aug 4, 2019


Babel plugin to transform async functions containing await expressions to the equivalent chain of Promise calls with use of minimal helper functions.

Build Status


async function fetchAsObjectURL(url) {
    const response = await fetch(url);
    const blob = await response.blob();
    return URL.createObjectURL(blob);


const fetchAsObjectURL = _async(function(url) {
	return _await(fetch(url), function(response) {
		return _await(response.blob(), URL.createObjectURL);

Output with hoist enabled:

function _response$blob(response) {
	return _await(response.blob(), URL.createObjectURL);
const fetchAsObjectURL = _async(function(url) {
	return _await(fetch(url), _response$blob);

Output with inlineHelpers enabled:

const fetchAsObjectURL = function(url) {
	try {
		return Promise.resolve(fetch(url)).then(function(response) {
			return Promise.resolve(response.blob()).then(URL.createObjectURL);
	} catch(e) {
		return Promise.reject(e);

JavaScript Language Features

Full Support

  • async/await
  • for/while/do loops (including loops that would exhaust stack if dispatched recursively)
  • switch statements (including fallthrough and default cases)
  • conditional expressions
  • logical expressions
  • try/catch
  • break/continue statements (on both loops and labeled statements)
  • throw expressions
  • Function hoisting
  • Variable hoisting
  • Arrow functions
  • Methods
  • arguments
  • this
  • Proper member dereference order of operations
  • Standards-compliant event loop scheduling

Partial Support

  • Function.length: async functions will often return a length of 0 (when the _async wrapper is used)

No support

  • eval: impossible to support without deep hooks into the runtime
  • Async generator functions: not implemented or planned
  • rewrite pass removes function name instrumentation
  • new AsyncFunction(...): impossible to support without shipping babel and the plugin in the output
You can’t perform that action at this time.