I'm trying to build nthRoot function in c++ and then embed it in my node js project.
the problem is all the tutorials that are on the web are for an old v8 version and don't work in node 12+
I'm not a c++ programmer
#include <node.h>
#include <iostream>
using namespace v8;
using namespace std;
double NthRoot(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
int n = args[0]->IntegerValue();
double degree = args[1]->DoubleValue();
double result = std::pow(n, 1.0/degree);
args.GetReturnValue().Set(result);
}
void Initialize(Local<Object> exports) {
NODE_SET_METHOD(exports, "nthroot", NthRoot);
}
NODE_MODULE(addon, Initialize);