napi_type_tag_object
napi_status napi_type_tag_object(napi_env env,
napi_value js_object,
const napi_type_tag* type_tag); [in] env:API 被调用时所处的环境。[in] js_object:要标记的 JavaScript 对象或 外部。[in] type_tag:用于标记该对象的标签。
如果 API 成功,则返回 napi_ok。
🌐 Returns napi_ok if the API succeeded.
将 type_tag 指针的值与 JavaScript 对象关联起来。然后可以使用 napi_check_object_type_tag() 来比较附加到对象上的标签与插件所拥有的标签,以确保对象具有正确的类型。
🌐 Associates the value of the type_tag pointer with the JavaScript object or
external. napi_check_object_type_tag() can then be used to compare the tag
that was attached to the object with one owned by the addon to ensure that the
object has the right type.
如果对象已经有关联的类型标记,此 API 将返回 napi_invalid_arg。
🌐 If the object already has an associated type tag, this API will return
napi_invalid_arg.