fix: insert inserts 1 more item than expected for rational index #174
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #issue_nr - no issue, just PR
All Submissions:
New Feature Submissions:
Changes to Core Features:
Hi @vitoke ,
first thanks for this project I really like the ideas and I did some performance testing: WOW
I tried appending to lists, prepending list and inserting in the middle of a list. To be honest, I might not have been the best Idea to use length/2 to find the index to insert to, but I did not expect the list to get 2 extra items instead of just the one I wanted to insert.
In my opinion it should not happen. Reason was insert uses splice, and splice uses take and take had a problem when rational numbers are used as index. One more time it makes me sad, typescript has no concept of integer.
The first commit is to create tests to show the error. Second commit is the fix, to use Math.floor on input index in take.
Test placement might not be ideal, this project is huge!
Thanks for your work,
Dennis