4 ms·
Ask HN: Is it possible to write a JavaScript runtime with "await by default"?
So that this code:
```
let a = await aFuncThatReturnPromise();
console.log(a)
```
becomes the following and does the same thing:
```
let a = aFuncThatReturnPromise();
console.log(a)
```
For sometimes I do not want wait, use:
```
let a = nowait aFuncThatReturnPromise();
```
- deleted 3y ago[deleted]
- aurareturn 3y agoNo, that's not possible. Console.log(a) will always run and finish before your async function finishes in the example that you want.
- numtel 3y agoWe used to use fibers before promises to do this. But don't do this. https://www.npmjs.com/package/fibers https://www.npmjs.com/package/fibers
- petercooper 3y agoRather than changing the semantics of JavaScript, which could cause confusion, you'd probably be better off implementing a compile-to-JS language like CoffeeScript and implementing that as the default behavior.