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: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
3401cad980
commit
ad6a6450c9
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user