I guess the real bug is that the code to get the next accesses the original items array whereas the map function runs on a filtered array from which items may be removed.
Just don't have deleted items and all will be fine...
1 3I'd split it in two parts.
1. const filtered = items.filter ...
2. return filtered .map ....
2 1Not sure if there would be performance and/or additional memory costs though.
I probably cannot count on the compiler to optimize the code. :-)
1 1Samuel
@samuel.fm
No it’s perform exactly the same, the runtime would totally be able to deal with that
1