Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
throwitaway1123
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
31.
▲
by
throwitaway1123
2y ago
Agreed. Frontend frameworks often do spend a lot of time thinking about the accessibility concerns associated with client side routing, so it's not absurd to consider this question in scope for a frontend library that handles DOM updat
32.
▲
by
throwitaway1123
2y ago
It's ultimately just a little event listener function that accepts a Request object and returns a Response object. I bundled the service worker by running a quick `npx esbuild --minify --bundle --outfile=sw.js sw.ts` command, and it pr
33.
▲
by
throwitaway1123
2y ago
> They don't work offline This isn't true. Offline functionality is the raison d'être for Service Workers. You can run an entire HTTP request router on the client to respond to requests while offline: https://ho
34.
▲
by
throwitaway1123
2y ago
> The MDN page has the deprecation notice for the `shadowRoot` property. The `shadowRoot` property of the ElementInternals object is not deprecated: https://developer.mozilla.org/en-US/docs/Web/API/E
35.
▲
by
throwitaway1123
2y ago
The only reason I avoid linking to that MDN page is because I think it does a bad job of actually assembling all of the pieces together into a working example. That's why I linked specifically to the component hydration section, which
36.
▲
by
throwitaway1123
2y ago
> Wtf is a shadowroot? In the Document Object Model (DOM), every document has a root node, which you can retrieve by calling `getRootNode()` on any node in the document (e.g. `document.getRootNode()` or `document.body.getRootNode()`). Cu
37.
▲
by
throwitaway1123
2y ago
> I'm not sure that's even that correct. If you write code using browser APIs that are currently standardised, your code will work indefinitely, whether or not you use Web Components, React, or jQuery. The most charitable inter
38.
▲
by
throwitaway1123
2y ago
Promisify converts a callback based function into a promise returning function [1]. If the function has a `promisify.custom` method, `promisify` will simply return the `promisify.custom` method instead of wrapping the original function. Cal
39.
▲
by
throwitaway1123
2y ago
TypeScript has the equivalent of what you're describing via the `Parameters` and `ReturnType` utility types [1][2], and I've found these types indispensable. So you can do the following: type R = ReturnType<typeof someFunct
40.
▲
by
throwitaway1123
2y ago
I don't want to get mired in a theoretical discussion about what promise cancellation would hypothetically look like, and would rather instead look at some concrete code. If you reproduce the memory leak from that original Node Github
41.
▲
by
throwitaway1123
2y ago
> This isn't actually about removing the promise (completion) listener, but the fact that promises are not cancelable in JS. You've made an interesting point about promise cancellation but it's ultimately orthogonal to the
42.
▲
by
throwitaway1123
2y ago
This doesn't even really appear to be a flaw in the Promise.race implementation [1], but rather a natural result of the fact that native promises don't have any notion of manual unsubscription. Every time you call the then method
43.
▲
by
throwitaway1123
2y ago
> In C#, awaiting for things which never complete is not that bad, the standard library has Task.WhenAny() method for that. It's not that bad in JS either. JS has both Promise.any and Promise.race that can trivially set a timeout to
44.
▲
by
throwitaway1123
2y ago
Node is the only major outlier. Bun supports this convention as well: https://bun.sh/docs/api/http#export-default-syntax
45.
▲
by
throwitaway1123
2y ago
> The front end bundler ecosystem has been a hot mess forever though. The bundler situation wasn't ideal for a few years, but I've been really happy with esbuild lately. It's incredibly fast, has zero dependencies (besides
46.
▲
by
throwitaway1123
2y ago
Yeah Vue 2 used object getters and setters, and there were a few tricky caveats. For example, setting an array item using an index wouldn't trigger the setters (e.g. `myArray[0] = ''`). You had to remember these edge cases an
47.
▲
by
throwitaway1123
2y ago
There are flags you can set to tune memory usage (notably V8's --max-old-space-size for Node and the --smol flag for Bun). And of course in advanced scenarios you can avoid holding strong references to objects with weak maps, weak sets
48.
▲
by
throwitaway1123
2y ago
> To get a real comparison they should have written a third system using their new architecture and the old langauge, but that would of course be hard to justify outside of academic research. Good point. You need a control group to make
49.
▲
by
throwitaway1123
2y ago
I agree with the general sentiment of your comment and I think there are several factors at play here. * The human brain is not capable of evaluating and re-evaluating every possible option amongst the plethora of technical choices develope
50.
▲
by
throwitaway1123
2y ago
This anecdote about the double equality operator might have originated from Eich's chat with Lex Fridman where he states (at about 5 minutes and 26 seconds) that during the original 10 day sprint JavaScript didn't support loose eq
51.
▲
by
throwitaway1123
2y ago
Yeah I should've said there's no Node API for making synchronous HTTP requests (unless you count executing a child process synchronously). Even the older http.request API used in Node prior to the introduction of fetch is async an
52.
▲
by
throwitaway1123
2y ago
You can perform file I/O in JavaScript synchronously. The localStorage API in the browser is synchronous (and in Node via the --experimental-webstorage option), and of course requiring a CommonJS module is also synchronous (and there a
53.
▲
by
throwitaway1123
2y ago
> See my comment here: https://news.ycombinator.com/item?id=41829905 Your comment isn't equivalent to the original code. Your one liner is doing this: `process.stdout.write('')` Jitl's example is doin
54.
▲
by
throwitaway1123
2y ago
Array.prototype.reduce can basically do almost anything a for loop can do, since it gives you access to state from one iteration to the next. The only reason I didn't remove the flatMap in my original example and convert it all to redu
55.
▲
by
throwitaway1123
2y ago
Yeah the comment I was originally responding to included a for loop (in the Pastebin link). My point is that if you're set on going down the functional route you don't need separate map and filter steps, you can just use flatMap w
56.
▲
by
throwitaway1123
2y ago
It's a little bit faster (on my machine at least) if you combine the filter and map into a flatMap (it's still not as performant as the imperative solution though). function process3(input) { return input .flatMap((n
57.
▲
by
throwitaway1123
2y ago
Apps weren't what drove people to the original iPhone (the original iPhone didn't have an app store). Apple was essentially the first mainstream company to commit fully to the current smartphone design — a flat, rectangular, portr
58.
▲
by
throwitaway1123
2y ago
The htmx author maintains his own swapping library which has more stars (although I wouldn't judge a project solely based on Github stars): https://github.com/bigskysoftware/idiomorph?tab=readme-ov-fi...
59.
▲
by
throwitaway1123
2y ago
Multicore OCaml finally landed a few years ago: https://news.ycombinator.com/item?id=34013767
60.
▲
by
throwitaway1123
2y ago
> if your email provider attempts to scan urls to see where they actually go you end up giving them an auth token One way you can handle this is to place the token in the hash portion of the url (which doesn't get sent to servers du
More ›