Skip to content

Commit 7841713

Browse files
committed
doc: clarify length param in buffer.write
`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)
1 parent 4fedb70 commit 7841713

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

doc/api/buffer.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Buffer
1+
# Buffer
22

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

@@ -1994,8 +1994,11 @@ added: v0.1.90
19941994
* `string` {string} String to write to `buf`.
19951995
* `offset` {integer} Number of bytes to skip before starting to write `string`.
19961996
**Default:** `0`.
1997-
* `length` {integer} Maximum number of bytes to write. **Default:**
1998-
`buf.length - offset`.
1997+
* `length` {integer} Maximum number of bytes to write (written bytes will not
1998+
exceed `buf.length - offset`). **Default:** `buf.length - offset`.
1999+
If the buffer has sufficient space from the offset, the string is written upto
2000+
`length`. If the buffer is short in space, only `buf.length - offset`
2001+
bytes are written.
19992002
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
20002003
* Returns: {integer} Number of bytes written.
20012004

0 commit comments

Comments
 (0)