GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: clarify `length` param in `buffer.write` by HarshithaKP · Pull Request #32119 · nodejs/node

Conversation

@HarshithaKP

@HarshithaKP HarshithaKP commented Mar 6, 2020

Copy link
Copy Markdown
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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to Node.js documentation. labels Mar 6, 2020
HarshithaKP added a commit to HarshithaKP/node that referenced this pull request Mar 6, 2020
@HarshithaKP
test: buffer.write with longer string scenario
2fdbb5e
Make sure longer strings are written up to the buffer end

Refs: nodejs#32119
@HarshithaKP HarshithaKP mentioned this pull request Mar 6, 2020
test: buffer.write with longer string scenario #32123
Closed
2 of 4 tasks
BridgeAR
BridgeAR reviewed Mar 9, 2020
View reviewed changes
Comment thread doc/api/buffer.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Mar 10, 2020
View reviewed changes
Comment thread doc/api/buffer.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Mar 11, 2020
View reviewed changes
addaleax pushed a commit that referenced this pull request Mar 12, 2020
@HarshithaKP @addaleax
test: buffer.write with longer string scenario
7fcb8da
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

addaleax commented Mar 13, 2020

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HarshithaKP
doc: clarify length param in buffer.write
7841713
`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
HarshithaKP force-pushed the clarify_buffer.write_length branch from 73ae863 to 7841713 Compare March 13, 2020 10:34
@HarshithaKP

HarshithaKP commented Mar 13, 2020

Copy link
Copy Markdown
Member Author

@addaleax, thanks. Rebased it. PTAL.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HarshithaKP
fixup: fix some rebase issues
661c800
addaleax
addaleax reviewed Mar 13, 2020
View reviewed changes
Comment thread doc/api/buffer.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@HarshithaKP
fixup: address review comment
28d0f9b
BridgeAR pushed a commit that referenced this pull request Mar 17, 2020
@HarshithaKP @BridgeAR
test: buffer.write with longer string scenario
0dd6e4a
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
@HarshithaKP @MylesBorins
test: buffer.write with longer string scenario
08edf53
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
addaleax reviewed Mar 29, 2020
View reviewed changes
Comment thread doc/api/buffer.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

HarshithaKP added 3 commits March 30, 2020 03:07
@HarshithaKP
fixup: address review comment
34e55ec
@HarshithaKP
fixup : bring back deleted number
b0e0bbe
@HarshithaKP
fixup: bring back deleted number
6956024
addaleax
addaleax reviewed Mar 30, 2020
View reviewed changes
Comment thread doc/api/buffer.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax approved these changes Mar 30, 2020
View reviewed changes
addaleax pushed a commit that referenced this pull request Apr 5, 2020
@HarshithaKP @addaleax
doc: clarify length param in buffer.write
d03d9a0
`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

addaleax commented Apr 5, 2020

Copy link
Copy Markdown
Member

Landed in d03d9a0

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax closed this Apr 5, 2020
BethGriggs pushed a commit that referenced this pull request Apr 7, 2020
@HarshithaKP @BethGriggs
doc: clarify length param in buffer.write
f11c7a6
`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
@HarshithaKP @targos
doc: clarify length param in buffer.write
0f1f572
`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 targos mentioned this pull request Apr 13, 2020
v13.13.0 release proposal #32813
Merged
targos pushed a commit that referenced this pull request Apr 22, 2020
@HarshithaKP @targos
test: buffer.write with longer string scenario
914eddd
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
@HarshithaKP @targos
doc: clarify length param in buffer.write
b4ba9b8
`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 targos mentioned this pull request Apr 22, 2020
v12.16.3 release proposal #33009
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@BridgeAR BridgeAR BridgeAR left review comments
@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

buffer Issues and PRs related to the buffer subsystem. doc Issues and PRs related to Node.js documentation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@HarshithaKP @addaleax @jasnell @BridgeAR @nodejs-github-bot
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.