napi-rs/crates/napi/src
nihohit 1cf32631bf
fix(napi): typed arrays ref shouldn't use offset. (#1376)
Notice from the n-api docs that the data returned from
`napi_get_typedarray_info` is already adjusted by the byte offset.
https://nodejs.org/api/n-api.html#napi_get_typedarray_info

This means that when `as_ref`/`as_mut` apply the byte offset, the
offset is in practice applied twice.
This wasn't caught in tests because no test tried to modify a typed
array with a byte offset, and the test didn't us the typed array
structs, only `JsTypedArray`. If you want, I can modify the rest of the
functions in examples/napi-compt-mode/src/arraybuffers.rs
and the matching tests, to test all typed arrays.

IMO the `byte_offset` field can be removed entirely from the struct,
but I wanted to submit a minimal PR.
2022-11-30 20:54:13 +08:00
..
bindgen_runtime fix(napi): typed arrays ref shouldn't use offset. (#1376) 2022-11-30 20:54:13 +08:00
js_values feat(napi): add threadsafe deferred values (#1306) 2022-10-03 13:00:48 +08:00
async_cleanup_hook.rs
async_work.rs fix(napi): clippy error on 1.58 2022-01-14 11:21:03 +08:00
call_context.rs refactor(napi): remove compatible Either struct 2021-11-25 17:53:41 +08:00
cleanup_env.rs
env.rs feat(napi): add threadsafe deferred values (#1306) 2022-10-03 13:00:48 +08:00
error.rs chore(napi): including type message in error message (#1350) 2022-10-24 00:16:30 +08:00
lib.rs feat(napi): add threadsafe deferred values (#1306) 2022-10-03 13:00:48 +08:00
status.rs
task.rs feat(napi): implement AsyncTask with AbortSignal support 2021-11-06 13:51:54 +08:00
threadsafe_function.rs fix(napi): segfault when ThreadsafeFunction's callback closure captures data (#1281) 2022-08-20 22:40:26 +08:00
tokio_runtime.rs fix(napi): return the join handle when spawning a tokio task. (#1351) 2022-11-15 11:50:25 +08:00
value_type.rs feat(napi): BigInt codegen support 2021-11-11 16:18:25 +08:00
version.rs fix(napi): correct the CString usage 2021-11-15 16:55:13 +08:00