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` · nodejs/node@b4ba9b8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • buffer.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+9-2Lines changed: 9 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1994,8 +1994,8 @@ 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`.
19991999
* `encoding` {string} The character encoding of `string`. **Default:** `'utf8'`.
20002000
* Returns: {integer} Number of bytes written.
20012001

@@ -2011,6 +2011,13 @@ const len = buf.write('\u00bd + \u00bc = \u00be', 0);
20112011

20122012
console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
20132013
// Prints: 12 bytes: ½ + ¼ = ¾
2014+
2015+
const buffer = Buffer.alloc(10);
2016+
2017+
const length = buffer.write('abcd', 8);
2018+
2019+
console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);
2020+
// Prints: 2 bytes : ab
20142021
```
20152022

20162023
### `buf.writeBigInt64BE(value[, offset])`

0 commit comments

Comments
0 (0)
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.