napi-rs/examples/napi-compat-mode
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
..
__test__ fix(napi): typed arrays ref shouldn't use offset. (#1376) 2022-11-30 20:54:13 +08:00
src fix(napi): typed arrays ref shouldn't use offset. (#1376) 2022-11-30 20:54:13 +08:00
build.rs Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
Cargo.toml style: format toml files 2022-02-11 10:46:17 +08:00
package.json chore: make example and bench package private 2022-02-09 20:42:00 +08:00