-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.
Description
Buffer.concat
returns a new Buffer instance that contains all given buffers combined. However, if the array of buffers that is passed has length 1, the original buffer from that array is returned as-is. Not a copy. That means that manipulation of Buffer.concat
's output has no effect on the source buffers if they had length > 1, yet alters the source buffer when length == 1.
This seems very unpredictable (Array.prototype.concat for example always returns a copy) and is bound to at least confuse people, and at worst cause weird bugs.
Original discussion: #1825 (comment)
Metadata
Metadata
Assignees
Labels
bufferIssues and PRs related to the buffer subsystem.Issues and PRs related to the buffer subsystem.