napi_is_buffer


napi_status napi_is_buffer(napi_env env, napi_value value, bool* result) 
  • [in] env:调用该 API 时所处的环境。
  • [in] value:要检查的 JavaScript 值。
  • [out] result:给定的 napi_value 是否表示 node::BufferUint8Array 对象。

如果 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.】