Get the pointer backing a TypedArray or ArrayBuffer
Use this to pass TypedArray or ArrayBuffer to C functions.
This is for use with FFI functions. For performance reasons, FFI will not automatically convert typed arrays to C pointers.
Symbol
Get the pointer backing a TypedArray or ArrayBuffer
Use this to pass TypedArray or ArrayBuffer to C functions.
This is for use with FFI functions. For performance reasons, FFI will not automatically convert typed arrays to C pointers.
the typed array or array buffer to get the pointer for
optional offset into the view in bytes
From JavaScript:
const array = new Uint8Array(10);
const rawPtr = ptr(array);
myFFIFunction(rawPtr);
To C:
void myFFIFunction(char* rawPtr) {
// Do something with rawPtr
}