Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d226418

Browse filesBrowse 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
Copy full SHA for d226418

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.