napi_is_buffer
napi_status napi_is_buffer(napi_env env, napi_value value, bool* result) -
[in] env:调用 API 的环境。¥
[in] env: The environment that the API is invoked under. -
[in] value:要检查的 JavaScript 值。¥
[in] value: The JavaScript value to check. -
[out] result:给定的napi_value是否代表node::Buffer或Uint8Array对象。¥
[out] result: Whether the givennapi_valuerepresents anode::BufferorUint8Arrayobject.
如果 API 成功,则返回 napi_ok。
¥Returns napi_ok if the API succeeded.
该 API 检查传入的 Object 是缓冲区还是 Uint8Array。如果调用者需要检查该值是否是 Uint8Array,则应首选 napi_is_typedarray。
¥This API checks if the Object passed in is a buffer or Uint8Array.
napi_is_typedarray should be preferred if the caller needs to check if the
value is a Uint8Array.