A.Franzen A.Franzen - 2 months ago 9
Javascript Question

How to access Local<String> in a node.js AddOn

I've written an Addon for node.js in which I want to use the arguments passed to my c++ code.

void tdlNodeAddOnClass::my_func( const FunctionCallbackInfo<Value>& args)
{
Isolate* isolate = args.GetIsolate();

if ( args[0]->IsString() )
{
Local<String> Value = args[0]->ToString();
}
}


How can I access the actual c-style buffer ?
Is there any better documentation or tutorial than the v5.6.0 Documentation?

Answer

You could use something like this:

Isolate* isolate = args.GetIsolate();
if (args[0]->IsString()) {
  Local<String> val = args[0]->ToString();
  Utf8Value str(isolate, val);
}

You could then access the underlying char * by doing *str

Comments