Skip to content

Buffer created using new Buffer(buffer) has a different ArrayBuffer from the original one #4341

Closed
@ghost

Description

Hope the title describes the issue correctly:)

Codes:

var typed_array = new Uint8Array(6);
for(var i = 0; i < typed_array.length; i++){
  typed_array[i] = i;
}

var array_buffer = typed_array.buffer;
console.log("byteLength of ArrayBuffer : " + array_buffer.byteLength);

var node_buffer = new Buffer(array_buffer);
console.log("Node Buffer : ");
console.log(node_buffer);

console.log("byteLength of ArrayBuffer in Node Buffer : ", node_buffer.buffer.byteLength);

var another_node_buffer = new Buffer(node_buffer);
console.log("Another Node Buffer : ");
console.log(another_node_buffer);

console.log("byteLength of ArrayBuffer in Another Node Buffer : ", another_node_buffer.buffer.byteLength);

node_buffer.buffer is different from another_node_buffer.buffer !

image

Metadata

Metadata

Assignees

Labels

bufferIssues and PRs related to the buffer subsystem.docIssues and PRs related to the documentations.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions