Skip to content

Commit d373b2f

Browse files
vsemozhetbytaddaleax
authored andcommitted
doc: fix examples in buffer.md to avoid confusion
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 <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 7a39a44 commit d373b2f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/api/buffer.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Buffer
1+
# Buffer
22

33
> Stability: 2 - Stable
44
@@ -404,14 +404,14 @@ are unknown and *could contain sensitive data*. Use
404404
Example:
405405

406406
```js
407-
const buf = new Buffer(5);
407+
const buf = new Buffer(10);
408408

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

412412
buf.fill(0);
413413

414-
// Prints: <Buffer 00 00 00 00 00>
414+
// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
415415
console.log(buf);
416416
```
417417

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

525525
```js
526-
const buf = Buffer.allocUnsafe(5);
526+
const buf = Buffer.allocUnsafe(10);
527527

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

531531
buf.fill(0);
532532

533-
// Prints: <Buffer 00 00 00 00 00>
533+
// Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
534534
console.log(buf);
535535
```
536536

0 commit comments

Comments
 (0)