Closed sockmaster27 closed 8 months ago
@sockmaster27 are you using any transpilers that could be polyfilling or transforming typed arrays?
I am not ables to reproduce with a simple test:
use neon::prelude::*;
#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
cx.export_function("array", |mut cx| {
JsInt16Array::from_slice(&mut cx, &[0, 1, 2, 3])
})?;
Ok(())
}
npm install
node -e 'console.log(require(".").array() instanceof Int16Array)'
# true
Internally, Neon is calling napi_create_typed_array
.
It appears to be a problem with Jest. Sorry for the inconvenience.
When returning a typed array, like
JsInt16Array
for example, the following JavaScript expression will evaluate tofalse
:Using Jest, this assertion
fails and reports the following:
This makes me suspect that Neon is using a constructor function with an identical name, but different equality identity.