I am new to Nan and I want to get rid of the following code snippet

But before that I need to understand what exactly is being returned from 
this method.

Local<Object> obj;

NAN_METHOD(process) {
    if (info.Length() == 0 || !info[0]->IsObject()) {
 std::cerr << "Must pass event object as first argument" << std::endl;
    info.GetReturnValue().Set(Nan::Null());
    return;
  }

  auto req = info[0]->ToObject();
  auto program = Nan::Get(req, 
Nan::New<String>("program").ToLocalChecked()).ToLocalChecked();
  auto message = Nan::Get(req, 
Nan::New<String>("message").ToLocalChecked()).ToLocalChecked();
  if (!program->IsString() || !message->IsString()) {
    std::cerr << "Must provide program and message keys in event object" << 
std::endl;
    info.GetReturnValue().Set(Nan::Null());
    return;
  }


    Nan::Utf8String app(Nan::To<String>(program).ToLocalChecked());
    Nan::Utf8String msg(Nan::To<String>(message).ToLocalChecked());

    obj = req;
    match(*msg, msg.length(), *app, app.length());
    info.GetReturnValue().Set(obj);
}
program and message both are strings.

match is a C method that is being called with return type void.

1)What is info.GetReturnValue().Set(obj) doing? Is this making any changes 
to obj because of some manipulation in the match function?

2)What is being returned from this method?

Thanks


-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/c4b88940-1c76-4d31-a23a-16ee4f4dc251%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to