Skip to content
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

doc: fix doc for Buffer.readInt32LE() #5890

Closed
wants to merge 2 commits into from
Closed

doc: fix doc for Buffer.readInt32LE() #5890

wants to merge 2 commits into from

Conversation

ghaiklor
Copy link
Contributor

Pull Request check-list

  • Is the commit message formatted according to [CONTRIBUTING.md][0]?
  • Is a documentation update included (if this change modifies
    existing APIs, or introduces new ones)?

Affected core subsystem(s)

doc

Description of change

Update example and signature for readInt32LE method. It fixes #5889.

Update example and signature for readInt32LE method.
@jasnell
Copy link
Member

jasnell commented Mar 24, 2016

LGTM

@jasnell jasnell added buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations. labels Mar 24, 2016
@cjihrig
Copy link
Contributor

cjihrig commented Mar 24, 2016

LGTM. Do the other similar methods have the same problem? If so, might as well fix those too.

@ghaiklor
Copy link
Contributor Author

@cjihrig @jasnell Each signature of read* methods has 0 <= offset <= buf.length - 8\4\2, starting from readDoubleBE().

I think all of them should be fixed to 0 <= offset < buf.length - 8\4\2. If so, I'll update PR.

@ghaiklor
Copy link
Contributor Author

Ouch, mistake was not in offsets. They are correct.

We have const buf = Buffer.from([1, -2, 3, 4]);. buf.readInt8() reads 8 bytes starting from offset. offset can be in range 0 <= offset <= 4 - 1 in our case. buf.readInt8(3) returns the correct result.

I'll update PR with correct version now.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 24, 2016

You're right. Thank you.

@bendiy
Copy link

bendiy commented Mar 25, 2016

@cjihrig I ran most of the other buf.readXXX() doc examples today and they seemed to be correct.

@cjihrig
Copy link
Contributor

cjihrig commented Mar 25, 2016

@bendiy thanks for investigating.

thefourtheye pushed a commit that referenced this pull request Mar 27, 2016
Update example of readInt32LE method. buf.readInt32LE(1) is supposed to
throw an error as it has only four elements and it tries to read 32
bits from three bytes.

Fixes: #5889
PR-URL: #5890
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@thefourtheye
Copy link
Contributor

LGTM and landed in 1213535. I squashed the commits and reworded the commit log a bit.

@ghaiklor ghaiklor deleted the doc/5889 branch March 27, 2016 07:11
evanlucas pushed a commit that referenced this pull request Mar 30, 2016
Update example of readInt32LE method. buf.readInt32LE(1) is supposed to
throw an error as it has only four elements and it tries to read 32
bits from three bytes.

Fixes: #5889
PR-URL: #5890
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@MylesBorins
Copy link
Contributor

should this be backported to v4?

evanlucas pushed a commit that referenced this pull request Mar 31, 2016
Update example of readInt32LE method. buf.readInt32LE(1) is supposed to
throw an error as it has only four elements and it tries to read 32
bits from three bytes.

Fixes: #5889
PR-URL: #5890
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@thefourtheye
Copy link
Contributor

@thealphanerd Yes, this should be backported to 4.x

MylesBorins pushed a commit that referenced this pull request Apr 9, 2016
Update example of readInt32LE method. buf.readInt32LE(1) is supposed to
throw an error as it has only four elements and it tries to read 32
bits from three bytes.

Fixes: #5889
PR-URL: #5890
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Apr 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

doc: Buffer buf.readInt32LE(offset[, noAssert]) example incorrect
6 participants