diff options
author | Aapo Alasuutari <aapo.alasuutari@gmail.com> | 2022-07-23 20:11:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-23 22:41:06 +0530 |
commit | e1cbd2364f536a1cef817961967e1738b89be734 (patch) | |
tree | 5e4c335cab348696a46558a0cd8d2be37160db8a /ext/ffi/00_ffi.js | |
parent | 2843160fc79a9651e9b2c2ddc4f834c15e138db6 (diff) |
feat(ext/ffi): Add support to get ArrayBuffers from UnsafePointerView (#15143)
Diffstat (limited to 'ext/ffi/00_ffi.js')
-rw-r--r-- | ext/ffi/00_ffi.js | 9 |
1 files changed, 5 insertions, 4 deletions
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) { |