upvote
Some utility stuff I copy paste between projects:

  - range, clamp, inIvl, enumerate, topK
  - groupBy (array to record), numeric / lexical array sorts
  - seeded rng
  - throttling
  - attachDragListener (like d3's mousedown -> mousemove -> mouseup)
  - Maps / Sets that accept non-primitive keys (ie custom hash)
So basically functions that every *dash variant includes.
reply
It's not standard unless it's in the actual standard.
reply
Those aren't a standard library for the language itself - they're not showing up in browsers, for example.
reply
Thanks but that doesn't answer my question. Forget node and bun then. What is missing from the standard library?
reply
There’s been a lot of progress (Temporal, URL, TextDecoder, Base64 encoding, etc.) but there are still gaps.

Math.clamp is a big one (it’s a TC39 proposal). I’d also love to have the stats functions that Python has (geometric mean, median, etc.).

On the more ambitious end: CSV reading/writing and IPv4/IPv6 manipulation.

reply
What standard library? Do you mean the built-in Array.x etc methods you get in the core language spec?
reply
In the browser, Javascript’s role is to add interactivity to the web page, and the API has a good surface area (even if not really pretty). People talk about the lack of standard library, but they can never say what’s missing.

https://developer.mozilla.org/en-US/docs/Web/API

The above seems fairly expansive, even if we remove all the experimental ones in the list.

reply
I suppose we could quibble about what exactly “standard library” means, but I’m presuming we’re talking about the web (rather than, say, Node or Bun). And to me it’s fair to use it to refer to all web APIs that are widely available. Things like crypto, ArrayBuffer, TextEncoder, File and the File System Access API, Intl, the Streams API, Window.performance, etc.
reply
String.splitRight, for one. (As an example: "www.a.north.website.com".splitRight(".", 3) == ["www.a.north", "website", "com"].)
reply
Python and Rust have such a thing, but not e.g. Java, Go, C#. And I can't find any libraries on npm which do this. That seems like a very niche need, not actually the sort of thing whose absence causes people to have lots of npm dependencies.
reply
When would you want that when it wouldn't be covered by more domain-specific use cases?
reply
Most things in Remeda, ramda, rxjs, the methods in the Ruby stdlib, etc. would all be great to have. I use at least Remeda in every project when I can.
reply
We're talking about JS in browsers: many fewer options there, plus needing to support old devices.
reply