From e1cbd2364f536a1cef817961967e1738b89be734 Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Sat, 23 Jul 2022 20:11:06 +0300 Subject: feat(ext/ffi): Add support to get ArrayBuffers from UnsafePointerView (#15143) --- ext/ffi/00_ffi.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ext/ffi/00_ffi.js') diff --git a/ext/ffi/00_ffi.js b/ext/ffi/00_ffi.js index cdaf69e0d..ac8dda317 100644 --- a/ext/ffi/00_ffi.js +++ b/ext/ffi/00_ffi.js @@ -10,7 +10,6 @@ ObjectPrototypeIsPrototypeOf, PromisePrototypeThen, TypeError, - Uint8Array, } = window.__bootstrap.primordials; function unpackU64([hi, lo]) { @@ -107,9 +106,11 @@ } getArrayBuffer(byteLength, offset = 0) { - const uint8array = new Uint8Array(byteLength); - this.copyInto(uint8array, offset); - return uint8array.buffer; + return core.opSync( + "op_ffi_get_buf", + offset ? this.pointer + BigInt(offset) : this.pointer, + byteLength, + ); } copyInto(destination, offset = 0) { -- cgit v1.2.3