the typed array or array buffer to get the pointer for
Optional
byteOffset: numberoptional offset into the view in bytes
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.
From JavaScript:
const array = new Uint8Array(10);
const rawPtr = ptr(array);
myFFIFunction(rawPtr);
To C:
void myFFIFunction(char* rawPtr) {
// Do something with rawPtr
}
the typed array or array buffer to get the pointer for
Optional
byteOffset: numberoptional offset into the view in bytes
Generated using TypeDoc
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.
Example
From JavaScript:
To C: