@@ -21,11 +21,30 @@ void RunCallback(napi_env env, const napi_callback_info info) {
2121 if (status != napi_ok) return ;
2222}
2323
24- void Init (napi_env env, napi_value exports, napi_value module ) {
24+ void RunCallbackWithRecv (napi_env env, const napi_callback_info info ) {
2525 napi_status status;
26- napi_property_descriptor desc = { " exports" , RunCallback };
27- status = napi_define_property (env, module , &desc);
26+
27+ napi_value args[2 ];
28+ status = napi_get_cb_args (env, info, args, 2 );
29+ if (status != napi_ok) return ;
30+
31+ napi_value cb = args[0 ];
32+ napi_value recv = args[1 ];
33+
34+ status = napi_call_function (env, recv, cb, 0 , nullptr , nullptr );
2835 if (status != napi_ok) return ;
2936}
3037
38+ void Init (napi_env env, napi_value exports, napi_value module ) {
39+ napi_status status;
40+ napi_property_descriptor desc[2 ] = {
41+ { " RunCallback" , RunCallback },
42+ { " RunCallbackWithRecv" , RunCallbackWithRecv }
43+ };
44+ for (int index = 0 ; index < 2 ; index++) {
45+ status = napi_define_property (env, exports, &desc[index]);
46+ if (status != napi_ok) return ;
47+ }
48+ }
49+
3150NODE_MODULE_ABI (addon, Init)
0 commit comments