0

I've written a node-addon using the Node API and want to handle both strings and String objects.

It's easy enough to use napi_typeof to find out the type, but a String object is a napi_object, not a napi_string.

How can I determine that the object is an instance of String?

I thought napi_instanceof would be useful, but I don't know what function to pass as the constructor.

(I'm using rust with napi-rs, but I think I can figure out how to get that to work if I know where to find the constructor for the call. Worst case, I fall back to using the node-api directly.)

bmacnaughton
  • 4,950
  • 3
  • 27
  • 36

0 Answers0