Skip to content

buffer: add Buffer.copyFrom(...)

This is a variation on Buffer.from(arrayBufferView) that copies the bytes and does not truncate when using a multibyte TypedArray. For instance,

Buffer.from(new Uint16Array([0xffff]))
<Buffer ff>

Buffer.copyBytesFrom(new Uint16Array([0xffff]))
<Buffer ff ff> 

Open to suggestions on a better name.

Fixes: https://github.com/nodejs/node/issues/43862

Merge request reports

Loading