Skip to content

Commit

Permalink
doc: suggest Buffer.alloc instead of Buffer#fill
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
not-an-aardvark authored and addaleax committed Dec 5, 2016
1 parent c0a2862 commit d226418
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ A zero-length `Buffer` will be created if `size <= 0`.

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

Example:

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

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

Example:
Expand Down

0 comments on commit d226418

Please sign in to comment.