Skip to content

Commit

Permalink
doc: clarify length param in buffer.write
Browse files Browse the repository at this point in the history
`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)
  • Loading branch information
HarshithaKP committed Mar 13, 2020
1 parent 4fedb70 commit 7841713
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Buffer
# Buffer

<!--introduced_in=v0.1.90-->

@@ -1994,8 +1994,11 @@ added: v0.1.90
* `string` {string} String to write to `buf`.
* `offset` {integer} Number of bytes to skip before starting to write `string`.
**Default:** `0`.
* `length` {integer} Maximum number of bytes to write. **Default:**
`buf.length - offset`.
* `length` {integer} Maximum number of bytes to write (written bytes will not
exceed `buf.length - offset`). **Default:** `buf.length - offset`.
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.
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
* Returns: {integer} Number of bytes written.

0 comments on commit 7841713

Please sign in to comment.