Async do expressions
Async do expressions can replace async IIFEs called in a synchronous scope.
| Type | TC39 | CoreJS | Babel | Civet | JS+ |
|---|---|---|---|---|---|
| Syntax | ✅ Stage 0 View | ✅ View | ✅ View | ✅ via Babel |
JS+ TypeScript
import { readFile } from 'node:fs';
async do { const file = await readFile('file.txt', 'utf8');
console.log(file);}import { readFile } from 'node:fs';
(async () => { const file = await readFile('file.txt', 'utf8');
console.log(file);})();