Passing an argument from Node.js to the C++ function, and returning the result to Node.js via a callback function.
Following the Node.js Addons Callback example, the example has been modified to involve a Number instead of a String.
Here's the example codeset from the Node.js Addons:
Local<Function> cb = Local<Function>::Cast(args[0]);
const unsigned argc = 1;
Local<Value> argv[argc] = { String::NewFromUtf8(isolate, "hello world") };
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
And here's the modified codeset, where value is a Number from a position in an Array:
Local<Function> cb = Local<Function>::Cast(args[1]);
const unsigned argc = 2;
Local<Value> argv[argc] = {Number::New(isolate, value)};
cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);