-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Buffer's indexOf does not seem to handle numbers correctly #7591
Labels
buffer
Issues and PRs related to the buffer subsystem.
Comments
I think this is the intended behaviour, because |
@nodejs/buffer |
Yes, this seems to be the correct behavior |
addaleax
added a commit
to addaleax/node
that referenced
this issue
Jul 8, 2016
Hopefully clarify the behaviour of `buffer.indexOf()` and `buffer.includes()` for numbers in that they will be truncated to uint8s. Add tests for that behaviour. Fixes: nodejs#7591
4 tasks
addaleax
added a commit
to addaleax/node
that referenced
this issue
Sep 9, 2016
Hopefully clarify the behaviour of `buffer.indexOf()` and `buffer.includes()` for numbers in that they will be truncated to uint8s. Add tests for that behaviour. Fixes: nodejs#7591 PR-URL: nodejs#7611 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Node seems to behave oddly when using indexOf (or includes) on a buffer
It seems that when a string or buffer is the parameter of indexOf it returns the index of the first byte that matches it; however, when a number is passed in it returns the index of the last byte that matched it, unless there are duplicates, then it behaves very oddly.
The text was updated successfully, but these errors were encountered: