concurrently.macro icon indicating copy to clipboard operation
concurrently.macro copied to clipboard

Transform your async function to be run concurrently much as possible

concurrently.macro

npm Babel Macro

Transforms your async function to be run concurrently much as possible.

Features

  • [x] Bundles multiple await expressions into a single Promise.all expression
  • [x] Simple dependency analysis
  • [ ] Graph dependency analysis
  • [ ] Limit maximum concurrency
  • [x] Insert side-effects

Install

yarn add concurrently.macro

Make sure you have babel-plugin-macros in your Babel config.

Usage

import concurrently from 'concurrently.macro';

concurrently(async () => {
  const a = await defer(1);
  const b = await defer(2);
});

This becomes:

async () => {
  let { 0: a, 1: b } = await Promise.all([defer(1), defer(2)]); 
};

Macros can handle more complex example like dependencies and destructuring!

LICENSE

MIT