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: clarify length param in buffer.write #32119

Closed

Conversation

HarshithaKP
Copy link
Member

buffer.write documentation has an incaccuracy w.r.t the length parameter:
It says default number of bytes written is buf.length - offset. Change it to:
If the buffer has sufficient space from the offset, the string is written upto length.
If the buffer is short in space, only buf.length - offset bytes are written.

proof:

#node
> let buf = Buffer.alloc(10)
undefined
> buf
<Buffer 00 00 00 00 00 00 00 00 00 00>
> buf.write(‘abcd’, 3)
4
> buf
<Buffer 00 00 00 61 62 63 64 00 00 00>
> buf = Buffer.alloc(10)
<Buffer 00 00 00 00 00 00 00 00 00 00>
> buf.write(‘abcd’, 9)
1
> buf
<Buffer 00 00 00 00 00 00 00 00 00 61>
>

Refs : #32104 (comment)

Thanks to @addaleax for her suggestion in the above comment, that lead to this finding.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to the documentations. labels Mar 6, 2020
HarshithaKP added a commit to HarshithaKP/node that referenced this pull request Mar 6, 2020
Make sure longer strings are written up to the buffer end

Refs: nodejs#32119
doc/api/buffer.md Outdated Show resolved Hide resolved
doc/api/buffer.md Outdated Show resolved Hide resolved
addaleax pushed a commit that referenced this pull request Mar 12, 2020
Make sure longer strings are written up to the buffer end

Refs: #32119

PR-URL: #32123
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@addaleax
Copy link
Member

@HarshithaKP There are conflicts here, can you rebase against master?

`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs : nodejs#32104 (comment)
@HarshithaKP
Copy link
Member Author

@addaleax, thanks. Rebased it. PTAL.

doc/api/buffer.md Outdated Show resolved Hide resolved
BridgeAR pushed a commit that referenced this pull request Mar 17, 2020
Make sure longer strings are written up to the buffer end

Refs: #32119

PR-URL: #32123
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
MylesBorins pushed a commit that referenced this pull request Mar 24, 2020
Make sure longer strings are written up to the buffer end

Refs: #32119

PR-URL: #32123
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
doc/api/buffer.md Outdated Show resolved Hide resolved
doc/api/buffer.md Outdated Show resolved Hide resolved
addaleax pushed a commit that referenced this pull request Apr 5, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@addaleax
Copy link
Member

addaleax commented Apr 5, 2020

Landed in d03d9a0

@addaleax addaleax closed this Apr 5, 2020
BethGriggs pushed a commit that referenced this pull request Apr 7, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
targos pushed a commit that referenced this pull request Apr 12, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
targos pushed a commit that referenced this pull request Apr 22, 2020
Make sure longer strings are written up to the buffer end

Refs: #32119

PR-URL: #32123
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
targos pushed a commit that referenced this pull request Apr 22, 2020
`buffer.write` documentation has an incaccuracy w.r.t the `length`
parameter: It says default number of bytes written is
`buf.length - offset`. Change it to:
If the buffer has sufficient space from the offset, the string is
written upto `length`.
If the buffer is short in space, only `buf.length - offset` bytes are
written.

Refs: #32104 (comment)

PR-URL: #32119
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
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.

5 participants