Re:TC39: Add Object.groupBy and Map.groupBy
by pmontra on Tuesday December 19, 2023 @04:48PM
(#38702145)
> When dealing with DB/API results, one can of course always say that such grouping in the client is an anti-pattern.
It depends on how many data you're working on. This groupBy is useful for filters in data tables.
If you have to download a zillion of records and filter them, client side filtering is a bad idea. If you have a few thousands of them, it could possibly be the faster solution overall.
Re:TC39: Add Object.groupBy and Map.groupBy
by moritzwarhier on Tuesday December 19, 2023 @05:58PM
(#38703122)
Exactly.
JS standard library is notoriously deficient.
This is a good addition in my view too, especially including Map.
When dealing with DB/API results, one can of course always say that such grouping in the client is an anti-pattern.
But in reality it can be reasonable and useful.
If you write one-off algorithms in JS to transform small amounts of data on the client, you probably habe done this.
And even for data-heavy applications, it could prove to be a performance benefit for functions that use Map instances during computation.
Though that's just wishful thinking until the runtime developers choose to optimize these functions, if possible.