-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent index after .remove() / .delete() #18
Comments
It doesn't seem like this ever worked with any version of traverse, and in general, JS traversal semantics become unreliable when you mutate something mid-iteration. However, even with |
Yes, the bug appears to have been dragged from the very start.
I do agree that mutating inside of a traversal operation could be unreliable, but in this particular code/case it can be reliable. Arrays are always walked from left to right (from index
Let's say that
Of course, the iterator should also be rewinded by 1 to prevent it from skipping 1 element. |
I agree with you, this is a bug worth fixing. |
Great!! I'll make sure to test the new version and report back when you release it! 🙏 |
I just tested this and the fix doesn't seem to be handling it.
The output is |
Using
.remove()
or.delete()
on arrays leads to inconsistent index of the following elements in the array.POC:
The expected output is
[ 'a' ]
, but the actual output is[ Function (anonymous), 'a' ]
The text was updated successfully, but these errors were encountered: