method BufferConstructor.copyBytesFrom
Jump to headingBufferConstructor.copyBytesFrom(view: TypedArray,offset?: number,length?: number,): BufferCopies the underlying memory of view into a new Buffer.
const u16 = new Uint16Array([0, 0xffff]);
const buf = Buffer.copyBytesFrom(u16, 1, 1);
u16[1] = 0;
console.log(buf.length); // 2
console.log(buf[0]); // 255
console.log(buf[1]); // 255
Parameters Jump to heading
Jump to headingview: TypedArrayThe {TypedArray} to copy.
optional
Jump to headingoffset: number = 0The starting offset within view.
optional
Jump to headinglength: number = view.length - offsetThe number of elements from view to copy.