pcattori
The Memories Folder
Re:Go-like channels in 10 lines of JavaScript
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".
Re:Go-like channels in 10 lines of JavaScript
on Saturday February 04, 2023 @06:31PM (#34659597)
The manifest is an artifact produced by the browser compilation, but it can be shared _before_ the browser compilation writes its results to disk.
I _could_ refactor to have "browser compilation phase 1", then assets manifest, and then "browser compilation phase 2", but that's not how I model it in my head. So prefer to use channels instead.
Re:Go-like channels in 10 lines of JavaScript
on Saturday February 04, 2023 @06:10PM (#34659417)
The main trick on display here is that you can store a reference to the `resolve` method of a promise that normally would have to be called within the promise definition itself.
Of course, you don't need a channel abstraction to do that. To me, channels are the most intuitive and self-contained way to solve the problem, so I wanted to use that model of concurrency in JS.
Re:Go-like channels in 10 lines of JavaScript
on Saturday February 04, 2023 @06:02PM (#34659358)
Its a Typescript-ism for asserting that the value is not `undefined`. So you're telling the typechecker to trust you on this one
Re:Go-like channels in 10 lines of JavaScript
on Saturday February 04, 2023 @05:52PM (#34659297)
That's correct. The last three paragraphs of the article cover this and include links to libraries that have "full" channel implementations.
Go-like channels in 10 lines of JavaScript
Your App's package.json Is Wrong
Snake_case_is_the_best_case
Re:Problems I Have with Python
on Wednesday January 25, 2017 @10:59AM (#13482439)
The point about "Inadequate data modelling facilities" is why I wrote Maps: https://github.com/pcattori/maps . Specifically, the "Named Maps" variants provide the same interface as `namedtuple` but for different levels of immutability/mutability.
Feedback/suggestions welcome!