From d226418b87c5d1c6eb52367ba691f9a907033e04 Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Thu, 1 Dec 2016 12:21:19 -0500 Subject: [PATCH] doc: suggest Buffer.alloc instead of Buffer#fill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig --- doc/api/buffer.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 093be3f09e9232..2eef3512a0c22a 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -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: