Open Swoorup opened 1 year ago
The uniqueness here is judged by the comparator function, if it returns 0 the elements are the same, as it does here:
if (b.ts == a.ts) return 0;
In this case, you can add a second check when timestamps are the same to check the values, something like:
if (b.ts === a.ts) {
return b.value > a.value ? -1 : 1;
}
But that would no longer make it unique and would push duplicates, no?
Well, then return 0
from the second check where you consider them to be duplicates.
If the data is new but is unique by for example timestamp, it appears that there isn't much way around to replacing it using
push
orunshift
?