File: addon.cc

package info (click to toggle)
node-addon-api 8.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,256 kB
  • sloc: cpp: 15,585; javascript: 5,664; ansic: 157; makefile: 7
file content (18 lines) | stat: -rw-r--r-- 519 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <napi.h>

Napi::Value Echo(const Napi::CallbackInfo& info) {
  Napi::Env env = info.Env();
  if (info.Length() != 1) {
    Napi::TypeError::New(env,
                         "Wrong number of arguments. One argument expected.")
        .ThrowAsJavaScriptException();
  }
  return info[0].As<Napi::Value>();
}

Napi::Object Init(Napi::Env env, Napi::Object exports) {
  exports.Set(Napi::String::New(env, "echo"), Napi::Function::New(env, Echo));
  return exports;
}

NODE_API_MODULE(NODE_GYP_MODULE_NAME, Init)