napi_get_cb_info
napi_status napi_get_cb_info(napi_env env,
napi_callback_info cbinfo,
size_t* argc,
napi_value* argv,
napi_value* thisArg,
void** data) [in] env:调用该 API 时所处的环境。[in] cbinfo:传递给回调函数的回调信息。[in-out] argc:指定提供的argv数组的长度,并接收实际的参数数量。argc可以通过传递NULL来选择性地忽略。[out] argv:要将参数复制到其中的napi_valueC 数组。如果参数数量多于提供的数量,则仅复制请求数量的参数。如果提供的参数少于声明的数量,其余的argv将填充表示undefined的napi_value值。通过传递NULL可以选择忽略argv。[out] thisArg:接收调用的 JavaScriptthis参数。通过传递NULL可以选择忽略thisArg。[out] data:接收回调的数据指针。可以通过传入NULL来选择性地忽略data。
如果 API 成功,则返回 napi_ok。
【Returns napi_ok if the API succeeded.】
此方法在回调函数中使用,用于从给定的回调信息中检索关于调用的详细信息,如参数和 this 指针。
【This method is used within a callback function to retrieve details about the
call like the arguments and the this pointer from a given callback info.】