p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

Code Action Idea: Parallelize Awaits #21

Open hediet opened 2 years ago

hediet commented 2 years ago
await writeFile(ancestorUri, 'some content');
await writeFile(input1Uri, 'some content');
await writeFile(input2Uri, 'some content');
await writeFile(resultUri, 'some content');

<->

Promise.all([
    writeFile(ancestorUri, 'some content'),
    writeFile(input1Uri, 'some content'),
    writeFile(input2Uri, 'some content'),
    writeFile(resultUri, 'some content'),
])

Ideally with detection if there are any dependencies

lgrammel commented 2 years ago

Thanks for the suggestion! What "dependencies" are you referring to here?

hediet commented 2 years ago

For example in this case:

const result1 = await writeFile(ancestorUri, 'some content');
const result2 = await writeFile(ancestorUri, 'some content');
await writeFile(input1Uri, result1 + result2);