Skip to content

Commit d226418

Browse files
not-an-aardvarkaddaleax
authored andcommitted
doc: suggest Buffer.alloc instead of Buffer#fill
Now that `Buffer.alloc` exists, there is no reason to recommend using `new Buffer(size).fill(0)` or `Buffer.allocUnsafe(size).fill(0)`. PR-URL: #10000 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent c0a2862 commit d226418

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/api/buffer.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ A zero-length `Buffer` will be created if `size <= 0`.
398398

399399
Unlike [`ArrayBuffers`][`ArrayBuffer`], the underlying memory for `Buffer` instances
400400
created in this way is *not initialized*. The contents of a newly created `Buffer`
401-
are unknown and *could contain sensitive data*. Use [`buf.fill(0)`][`buf.fill()`]
402-
to initialize a `Buffer` to zeroes.
401+
are unknown and *could contain sensitive data*. Use
402+
[`Buffer.alloc(size)`][`Buffer.alloc()`] instead to initialize a `Buffer` to zeroes.
403403

404404
Example:
405405

@@ -517,7 +517,7 @@ be less than or equal to the value of [`buffer.kMaxLength`]. Otherwise, a
517517

518518
The underlying memory for `Buffer` instances created in this way is *not
519519
initialized*. The contents of the newly created `Buffer` are unknown and
520-
*may contain sensitive data*. Use [`buf.fill(0)`][`buf.fill()`] to initialize such
520+
*may contain sensitive data*. Use [`Buffer.alloc()`] instead to initialize
521521
`Buffer` instances to zeroes.
522522

523523
Example:

0 commit comments

Comments
 (0)