目录

How do I distinguish the ArrayBuffer and Uint8Array objects created by ArkTS in native code?

Question

How do I distinguish the ArrayBuffer and Uint8Array objects created by ArkTS in native code?

Answer

  1. Use napi_is_arraybuffer to check whether the given object is an ArrayBuffer. If yes, true is returned.
  2. Use napi_is_typedarray to check whether the given object is a Uint8Array. If yes, true is returned.