Skip to content

Instantly share code, notes, and snippets.

@ramirezd42
Created October 25, 2017 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramirezd42/3c22c512e96e00db0dbd686d86fd3a37 to your computer and use it in GitHub Desktop.
Save ramirezd42/3c22c512e96e00db0dbd686d86fd3a37 to your computer and use it in GitHub Desktop.
ex_1
#include <nan.h>
void RunCallback(const Nan::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Function> cb = info[0].As<v8::Function>();
const unsigned argc = 1;
v8::Local<v8::Value> argv[argc] = { Nan::New("hello world").ToLocalChecked() };
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, argc, argv);
}
void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
Nan::SetMethod(module, "exports", RunCallback);
}
NODE_MODULE(addon, Init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment