Of course, one would never bother to write an add-on to simply echo back strings. It is more likely that you will want to expose an API or interface to your Node programs. Let’s create a simple calculator, with two methods: add and subtract. In this example, we will demonstrate how to pass arguments from Javascript to methods within an add-on, and to send any results back.
The complete code for this example will be found in your code bundle. The meat of the program can be seen in this snippet, where we define an interface for our two methods, each one expecting to receive two numbers as arguments:
#include <node.h>
namespace calculator_module {
using v8::Exception;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Number;
using v8::Object;
using v8::String;
using v8::Value;
void Add(const FunctionCallbackInfo<...