RunJS
RunJS copied to clipboard
Feature Request: Top level await
To try out things, top level await would be awesome. It is very annoying to write:
(async () => {
async function t() {}
await t();
})().catch(console.trace);
With top level await:
async function t() {}
await t();
There's currently no official Babel plugin for top-level await. When they release one I will certainly look into adding it.
However, you could wrap the input code automatically with an async function, or?
Unfortunately that would result in the line-by-line output for top level code no longer being possible.
Can you not calculate the offset?
I'm not sure what you mean by that, but I'm certain there's no simple solution here.
https://www.chromestatus.com/feature/5767881411264512#:~:text=Allow%20the%20%60await%60%20keyword%20at,modules%20and%20exposes%20implementation%20details.
Added above link to track when TLA is landing in Chromium
This shipped now according to the linked docs. Any idea if this will be implemented?
@hoegertn it's shipped with Chromium 89. RunJS is currently on Chromium 85. It's something I'll look further into after the upgrade. It's support is only in modules which may complicate its use in RunJS.
I would really like this as well. Any news @lukehaas ?
@wc-matteo it's currently not possible due to upstream limitations. I'm very keen to support top-level await so if anything changes this will be top priority.
Top level await would make runJS so much more useful, it would become a great playground for exploring and debugging various API
If you are looking for logging async functions in a convenient way, you could enable pipe operator for your convenience
const log = (fn)=>{
fn.then(r=>console.log(r))
}
asyncFunction() |> log
I would love to see this feature!
That would be great indeed, are there any news?
Just bought the software and this is the first issue I encounter in 30 seconds of using it... I'm sorry but it's 2023 and this is long overdue. I regret purchasing it without trying it out first.
it's 2023
I liked runjs but I think there are way better alternatives now and free.
it's 2023
I liked runjs but I think there are way better alternatives now and free.
@melMass any suggestions?
@melMass @TheNoim latest version (2.8.0
) supports top level await
, so this ticket can be closed.
https://github.com/lukehaas/RunJS/releases/tag/v2.8.0
@wc-matteo @timuric @jimmyn @hoegertn @letoast Top-level await is now supported. However, it's not compatible with displaying runtime values. For that reason, it is not enabled by default. You can enable top-level await from the settings: