1 #include <assert.h>
2 #include <node_api.h>
3
4 static int32_t increment = 0;
5
Hello(napi_env env,napi_callback_info info)6 static napi_value Hello(napi_env env, napi_callback_info info) {
7 napi_value result;
8 napi_status status = napi_create_int32(env, increment++, &result);
9 assert(status == napi_ok);
10 return result;
11 }
12
NAPI_MODULE_INIT()13 NAPI_MODULE_INIT() {
14 napi_value hello;
15 napi_status status =
16 napi_create_function(env,
17 "hello",
18 NAPI_AUTO_LENGTH,
19 Hello,
20 NULL,
21 &hello);
22 assert(status == napi_ok);
23 status = napi_set_named_property(env, exports, "hello", hello);
24 assert(status == napi_ok);
25 return exports;
26 }
27