Transforms your async function to be run concurrently much as possible.
- Bundles multiple await expressions into a single
Promise.all
expression - Simple dependency analysis
- Graph dependency analysis
- Limit maximum concurrency
- Insert side-effects
yarn add concurrently.macro
Make sure you have babel-plugin-macros
in your Babel config.
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!
MIT