ijavascript icon indicating copy to clipboard operation
ijavascript copied to clipboard

Support top-level await

Open Masterxilo opened this issue 5 years ago • 10 comments

x = await 1

should just work, like it does in the chrome dev console and node --experimental-repl-await.

For interactive use especially, this is much more convenient.

const result = await fetch("http://google.com")

versus

var result
fetch("http://google.com").then(x => result = x)

Masterxilo avatar Oct 12 '18 16:10 Masterxilo

This is still an experimental feature, if you want to test it, please use ijavascript-await.

n-riesco avatar Oct 13 '18 07:10 n-riesco

You can also do this:

(async () => {
 const request = require('async-request')
 let result = await request("http://google.com")
 console.log({result})
})()

geosp avatar Sep 17 '20 05:09 geosp

Is this still experimental or does it work in regular ijavascript now? I see ijavascript-await hasn't been updated for three years.

ezyang avatar Nov 20 '21 04:11 ezyang

Judging from https://github.com/n-riesco/ijavascript/compare/await?expand=1 looks like it's not merged

ezyang avatar Nov 20 '21 04:11 ezyang

People on this thread may be interested in https://github.com/n-riesco/ijavascript/pull/257

ezyang avatar Nov 20 '21 04:11 ezyang

Good news! Node.js v16.6+ (released at the end of July) finally supports top level await out of the box.

There is no need for ijavascript-await and I'll deprecate it now.

n-riesco avatar Nov 20 '21 18:11 n-riesco

:disappointed: I jumped the gun. When I wrote my previous message, I was testing directly on Node.js CLI. Unfortunately, ijavascript is affected by https://github.com/nodejs/node/issues/40898 .

I've undeprecated ijavascript-await and I'll publish a new releases including the updates in the latest ijavascript soon.

n-riesco avatar Nov 20 '21 20:11 n-riesco

What is the status on await support?

brandonmpetty avatar Aug 13 '23 22:08 brandonmpetty

I haven't looked into supporting await recently, but judging by https://github.com/nodejs/node/issues/45924 , I don't think it is.

I suppose ijavascript-await is still working (as I haven't had anyone opening issues for it).

n-riesco avatar Aug 15 '23 01:08 n-riesco

I suppose ijavascript-await is still working (as I haven't had anyone opening issues for it).

@n-riesco I ran into this issue while installing kernel of ijavascript-await - please have a look.

sohang3112 avatar Dec 12 '23 12:12 sohang3112