将 BufferSource 转换为 Uint8Array。
需要转换的 BufferSource。
Uint8Array。
const buffer = new ArrayBuffer(8);const u8a = bufferSource2U8a(buffer);console.log(u8a.byteLength); // 8const view = new DataView(buffer);const u8a2 = bufferSource2U8a(view);console.log(u8a2.byteLength); // 8 Copy
const buffer = new ArrayBuffer(8);const u8a = bufferSource2U8a(buffer);console.log(u8a.byteLength); // 8const view = new DataView(buffer);const u8a2 = bufferSource2U8a(view);console.log(u8a2.byteLength); // 8
将 BufferSource 转换为 Uint8Array。