From 7841713d7305727b326c80c038d74be1616390c5 Mon Sep 17 00:00:00 2001 From: Harshitha KP Date: Fri, 6 Mar 2020 01:10:40 -0500 Subject: [PATCH] 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 : https://github.com/nodejs/node/pull/32104#discussion_r388524733 --- doc/api/buffer.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index bffa5c18a9da7d..dfb65f8b2e46d7 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -1,4 +1,4 @@ -# Buffer + # Buffer @@ -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.