diff options
author | snek <snek@deno.com> | 2024-06-19 11:33:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 11:33:46 -0700 |
commit | 293a36f98d3614368d24f7804d2fc4191a54c0e3 (patch) | |
tree | bea097934bd7264318dba5762a369267d7ceea9e /cli/napi/node_api.rs | |
parent | 6c6ee02dfdb0f158a0aab20905e362100b2c3328 (diff) |
fix: more node-api fixes (#24220)
- add fallback impls of external string apis which always copy. after
upstream changes to rusty_v8 we can support non-copying api as well.
- `napi_get_buffer_data` needs to work on all TypedArray instances.
- Fixes: https://github.com/denoland/deno/issues/24209
- `target_defaults.default_configuration` is used by some modules to
find the corresponding node file from node-gyp
- `node_api_get_module_filename` expects the filename to be a `file:`
url.
Diffstat (limited to 'cli/napi/node_api.rs')
-rw-r--r-- | cli/napi/node_api.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/cli/napi/node_api.rs b/cli/napi/node_api.rs index 268715fa8..81cb800a7 100644 --- a/cli/napi/node_api.rs +++ b/cli/napi/node_api.rs @@ -426,22 +426,14 @@ fn napi_get_buffer_info( let env = check_env!(env); check_arg!(env, value); + // NB: Any TypedArray instance seems to be accepted by this function + // in Node.js. let Some(ta) = value.and_then(|v| v8::Local::<v8::TypedArray>::try_from(v).ok()) else { return napi_set_last_error(env, napi_invalid_arg); }; - let buffer_constructor = - v8::Local::new(&mut env.scope(), &env.buffer_constructor); - - if !ta - .instance_of(&mut env.scope(), buffer_constructor.into()) - .unwrap_or(false) - { - return napi_set_last_error(env, napi_invalid_arg); - } - if !data.is_null() { unsafe { *data = ta.data(); |