I am trying to pass an array from a node app to an add-on I have build using node-gyp. As performance is a major concern in this case, I am trying to use the most efficient ways to pass and parse the data. The issue I am encountering is passing an array and then converting it from a v8 array to a regular float* . The best solution I could find is:
- Grab the argument
Local<Array> buffer = args[0].As<Array>();
Iterate over it using a for loop to extract the data, like so:
for(int i=0 ; i < 512 ; i++) bufferArray[i] = buffer->Get(i)->NumberValue();
Where bufferArray
is an float array that I instantiated earlier.
Then, I pass bufferArray
to my c++ library that through a function that accepts a float*
.
Is there a better solution than this?