It was recently brought to my attention that the void* from an ArrayBuffer
created in JS can be retrieved from a TypedArray using
Object::GetIndexedPropertiesExternalArrayData(). Here's an example:
// JS side
var ui = new Uint8Array(new ArrayBuffer(16));
fillArray(ui);
// C++ side
void FillArray(const FunctionCallbackInfo<Value>& args) {
Local<Object> o = args[0].As<Object>();
char* data = static_cast<char*>(o->GetIndexedPropertiesExternalArrayData());
// Now have a pointer to the data
}
Wanted to check if this was intentional or just a side-effect of some internal
implementation details. Also whether it is "safe" to use or not.