• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <node_api.h>
2 #include "../../js-native-api/common.h"
3 #include <string.h>
4 
Method(napi_env env,napi_callback_info info)5 static napi_value Method(napi_env env, napi_callback_info info) {
6   napi_value world;
7   const char* str = "world";
8   size_t str_len = strlen(str);
9   NAPI_CALL(env, napi_create_string_utf8(env, str, str_len, &world));
10   return world;
11 }
12 
NAPI_MODULE_INIT()13 NAPI_MODULE_INIT() {
14   napi_property_descriptor desc = DECLARE_NAPI_PROPERTY("hello", Method);
15   NAPI_CALL(env, napi_define_properties(env, exports, 1, &desc));
16   return exports;
17 }
18