const wrap = fn => asde(util.promisify(fn)) const [err, res] = await wrap(fn)('foo') This should work already :) and yeah wrapping but...
-
-
Actually no, you only need the asde library https://www.npmjs.com/package/asde (by
@0x00A )2 replies 1 retweet 7 likes -
Replying to @juliangruber @yoshuawuyts and
I'm curious, what don't you like about try/catch blocks? Just the indentation?
1 reply 0 retweets 0 likes -
Replying to @timwis @juliangruber and
The fact that it isn’t concatenable, because it’s not an expression. It forces you to use non-constant variables.
1 reply 0 retweets 0 likes -
Replying to @seidtgeist @evilhackerdude and
Do you mean because const is block-scoped so using it inside of try restricts access to that block? And what do you mean by concatenable?
1 reply 0 retweets 0 likes -
Replying to @timwis @evilhackerdude and
Yeah, the indentation is what kills it for me. Also the vast majority of async/await examples leave out err handling somehow :/
2 replies 0 retweets 0 likes -
Replying to @yoshuawuyts @timwis and
yeah, having to do let v try { v = await fn() } catch (_) { ... } const val = v
1 reply 0 retweets 0 likes -
Replying to @juliangruber @yoshuawuyts and
Exactly. Would be cool if I could do: const v = try await fn catch NaN lol
2 replies 0 retweets 2 likes -
Replying to @seidtgeist @evilhackerdude and
I mean it doesn't get better in any way...having to use a flow control lib for basic async/await shows bad design again i guess
1 reply 0 retweets 3 likes -
Replying to @juliangruber @evilhackerdude and
Hm, how do other languages deal with it, like python I wonder
1 reply 0 retweets 0 likes
For Golang it's `res, err := somethingAsync; if err doSomething(err)`
-
-
Replying to @yoshuawuyts @juliangruber and
Oh I meant other languages that use try/catch
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.