0

I want to call some existing functions, but the function requires the CallbackInfo parameter, how do I initialize a CallbackInfo

Value b(const CallbackInfo& info)
{
  ...
}

Value a(const CallbackInfo& info)
{
  CallbackInfo newInfo = CallbackInfo::New();
  return b(newInfo);
}
januw a
  • 2,056
  • 5
  • 18
  • 39

1 Answers1

0
void b(const CallbackInfo& info)
{
  printf("function b\n");
}

void a(const CallbackInfo& info)
{
   auto js_this = info.This().As<Napi::Object>();

  if (js_this.Has("b") && js_this.Get("b").IsFunction())
  {
    js_this.Get("b").As<Napi::Function>().Call(info.This(), {});
  }
}
januw a
  • 2,056
  • 5
  • 18
  • 39