napi-rs/examples/napi-compat-mode/__test__
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
..
napi4 feat(napi): add threadsafe deferred values (#1306) 2022-10-03 13:00:48 +08:00
napi5 Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
napi6 Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
napi7 feat(cli): refactor cli build 2021-11-19 18:22:40 +08:00
napi8 Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
serde test: update snapshots format for ava@4 2022-01-04 11:04:45 +08:00
array.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
arraybuffer.spec.ts fix(napi): typed arrays ref shouldn't use offset. (#1376) 2022-11-30 20:54:13 +08:00
buffer.spec.ts fix(napi): use create_buffer/arrary_buffer if provided data is empty 2022-04-26 16:53:13 +08:00
class.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
cleanup-env.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
create-external.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
either.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
env.spec.ts fix(napi): missing coerce_to_bool on JsValue 2021-11-21 23:10:29 +08:00
function.spec.ts fix(napi): improve error propagation (#1303) 2022-09-14 17:03:11 +08:00
get-napi-version.spec.ts fix(napi-derive): BigInt in TypeScript should be bigint 2022-01-06 22:33:34 +08:00
global.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
js-value.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
napi-version.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
object.spec.ts chore: upgrade dependencies 2022-03-13 18:30:11 +08:00
object.spec.ts.md Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
object.spec.ts.snap test: update snapshots format for ava@4 2022-01-04 11:04:45 +08:00
spawn.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
string.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
string.spec.ts.md Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
string.spec.ts.snap test: update snapshots format for ava@4 2022-01-04 11:04:45 +08:00
symbol.spec.ts Introduce #[napi] procedural macro to automation development boilerplate (#696) 2021-09-23 01:29:09 +08:00
throw.spec.ts test: update snapshots format for ava@4 2022-01-04 11:04:45 +08:00