Re:Go-like channels in 10 lines of JavaScript
by gbuk2013 on Saturday February 04, 2023 @06:45PM
(#34659737)
Hmm, the way I see it is that this only makes a difference if your "more work" is async, in which case I would consider if the function needed refactoring instead - not possible to say with toy code of course. Something like:
If, however, "more work" is synchronous then the promise would not resolve until the next tick which puts you in the same place as before + extra overhead from a pair of extra promises.
[ Parent
| on HN ]
Re:Go-like channels in 10 lines of JavaScript
by pcattori on Saturday February 04, 2023 @07:33PM
(#34660161)
Yep, totally could do that. But I like I mentioned here (https://news.ycombinator.com/item?id=34659597) I wanted to keep the interfaces for `compileBrowser` and `compilerServer` since my mental model for it is that those two are "siblings".