Sorted (ordered) collection for JavaScript

I’m looking for sorted container for JavaScript. I’m using C++ std::set, https://en.cppreference.com/w/cpp/container/set and try porting my code to JavaScript. JavaScript Map is not ordered container. …

How can I count in Firebase the collections in a document

I know how to count how many Documents are in a collection in Firebase but how does it work the other way around. I have several collections in a document and I need to find out how many. (In my …

What is the best way to reduce and merge a collection of objects

So I reached a dilemma this week while trying to solve what seemed to be an easy problem, but I was wrong. Sample code: So the problem was being able to map through the array and merge/sum the values if their unique identifiers match. Any suggestions? End result would look something like this: Now of course the real application will not have statically typed ids, but they were written into this example. So please take that into consideration. Thanks in advance! Answer You could take an object for grouping and an array for adding the wanted properties.

Get first element of a collection that matches iterator function

I would like to achieve something like _.first with _.filter, that is, having a collection of elements, I’d like to get the first one (if exists) that matches a truth test (iterator). For example, …