Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Top level await #42

Closed
TheNoim opened this issue Jan 21, 2019 · 19 comments
Closed

Feature Request: Top level await #42

TheNoim opened this issue Jan 21, 2019 · 19 comments
Labels
enhancement New feature or request

Comments

@TheNoim
Copy link

TheNoim commented Jan 21, 2019

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();
@lukehaas
Copy link
Owner

lukehaas commented Feb 9, 2019

There's currently no official Babel plugin for top-level await. When they release one I will certainly look into adding it.

@lukehaas lukehaas added the enhancement New feature or request label Feb 9, 2019
@TheNoim
Copy link
Author

TheNoim commented Feb 10, 2019

However, you could wrap the input code automatically with an async function, or?

@lukehaas
Copy link
Owner

lukehaas commented Feb 10, 2019

Unfortunately that would result in the line-by-line output for top level code no longer being possible.

@TheNoim
Copy link
Author

TheNoim commented Feb 10, 2019

Can you not calculate the offset?

@lukehaas
Copy link
Owner

I'm not sure what you mean by that, but I'm certain there's no simple solution here.

@lukehaas
Copy link
Owner

@hoegertn
Copy link

This shipped now according to the linked docs. Any idea if this will be implemented?

@lukehaas
Copy link
Owner

@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.

@wc-matteo
Copy link

wc-matteo commented Nov 25, 2021

I would really like this as well. Any news @lukehaas ?

@lukehaas
Copy link
Owner

@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.

@timuric
Copy link

timuric commented Mar 11, 2022

Top level await would make runJS so much more useful, it would become a great playground for exploring and debugging various API

@timuric
Copy link

timuric commented Mar 11, 2022

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

@jimmyn
Copy link

jimmyn commented Jul 6, 2022

I would love to see this feature!

@melMass
Copy link

melMass commented Aug 13, 2022

That would be great indeed, are there any news?

@letoast
Copy link

letoast commented Feb 15, 2023

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.

@melMass
Copy link

melMass commented Feb 16, 2023

it's 2023

I liked runjs but I think there are way better alternatives now and free.

@Stiropor
Copy link

it's 2023

I liked runjs but I think there are way better alternatives now and free.

@melMass any suggestions?

@btecu
Copy link

btecu commented Mar 19, 2023

@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

@lukehaas
Copy link
Owner

@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:

Screenshot 2023-03-20 at 10 15 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

10 participants