1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

fix(cli/napi): napi_get_buffer_info accepts ArrayBufferView … (#19551)

... not just `Uint8Array`.

This PR aligns behavior with Node.js Node-API implementation.
This commit is contained in:
Dj 2023-06-21 13:11:58 +05:30 committed by GitHub
parent 544878cd2b
commit 6729e9c977
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1739,7 +1739,7 @@ fn napi_get_buffer_info(
check_env!(env); check_env!(env);
let env = unsafe { &mut *env }; let env = unsafe { &mut *env };
let value = napi_value_unchecked(value); let value = napi_value_unchecked(value);
let buf = v8::Local::<v8::Uint8Array>::try_from(value).unwrap(); let buf = v8::Local::<v8::ArrayBufferView>::try_from(value).unwrap();
let buffer_name = v8::String::new(&mut env.scope(), "buffer").unwrap(); let buffer_name = v8::String::new(&mut env.scope(), "buffer").unwrap();
let abuf = v8::Local::<v8::ArrayBuffer>::try_from( let abuf = v8::Local::<v8::ArrayBuffer>::try_from(
buf.get(&mut env.scope(), buffer_name.into()).unwrap(), buf.get(&mut env.scope(), buffer_name.into()).unwrap(),