Skip to content

Commit

Permalink
doc: fix examples in buffer.md to avoid confusion
Browse files Browse the repository at this point in the history
On some systems, some first bytes of allocated buffer can be zeroed
by default, so the example doesn't work well - the buffer looks zeroed
even before the fill.

Fixes: #9786
PR-URL: #9795
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
vsemozhetbyt authored and MylesBorins committed Mar 9, 2017
1 parent 020c90e commit 6d3c2d6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Buffer
# Buffer

> Stability: 2 - Stable
Expand Down Expand Up @@ -404,14 +404,14 @@ are unknown and *could contain sensitive data*. Use
Example:

```js
const buf = new Buffer(5);
const buf = new Buffer(10);

// Prints: (contents may vary): <Buffer 78 e0 82 02 01>
// Prints: (contents may vary): <Buffer 48 21 4b 00 00 00 00 00 30 dd>
console.log(buf);

buf.fill(0);

// Prints: <Buffer 00 00 00 00 00>
// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
console.log(buf);
```

Expand Down Expand Up @@ -523,14 +523,14 @@ initialized*. The contents of the newly created `Buffer` are unknown and
Example:

```js
const buf = Buffer.allocUnsafe(5);
const buf = Buffer.allocUnsafe(10);

// Prints: (contents may vary): <Buffer 78 e0 82 02 01>
// Prints: (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
console.log(buf);

buf.fill(0);

// Prints: <Buffer 00 00 00 00 00>
// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
console.log(buf);
```

Expand Down

0 comments on commit 6d3c2d6

Please sign in to comment.