It seems there is bug in applyChangesToArray function when deleting multiple items.
In applyChangesToArray function to apply changes array it is being sorted on index field on ASC order then with reduce function it is applying changes to it.
The bug is happening when removing element from array revisedArray.splice(index, 1).
Let's say we have array with length of 5 and we want to delete 5 elements from array. On every iteration index is going up and the size of array is going down, by the time you are deleting element with index 3 revisedArray length is 2 then it cant remove any element. at the end it returns remaining 2 elements.
I have extracted applyChangesToArray function logic from code. You can try it in typescrip playground. Code is provided below
It seems there is bug in
applyChangesToArray
function when deleting multiple items. InapplyChangesToArray
function to apply changesarray
it is being sorted on index field onASC
order then with reduce function it is applying changes to it. The bug is happening when removing element from arrayrevisedArray.splice(index, 1)
. Let's say we have array with length of 5 and we want to delete 5 elements from array. On every iteration index is going up and the size of array is going down, by the time you are deleting element with index 3revisedArray
length is 2 then it cant remove any element. at the end it returns remaining 2 elements. I have extractedapplyChangesToArray
function logic from code. You can try it in typescrip playground. Code is provided below