Iterate Napi::Object Properties (Keys) in Node.js C++ N-API

1.4k Views Asked by At

I am having a problem using c++ n-api api and I have reviewed the documentation here, and I do not see a way to iterate the keys of a Napi::Object. I must be missing something because this is possible in JavaScript, so it must be possible in the C++ API.

How can I list or iterate the keys (properties) in a Napi::Object.

1

There are 1 best solutions below

0
On BEST ANSWER

It seems the Doxygen documentation which Google surfaced at https://nodejs.github.io/node-addon-api/ is out-of-date.

The right place to look is on the Node.js Github repo at https://github.com/nodejs/node-addon-api/blob/master/napi.h

Looking at the correct header version, Napi::Object has a function GetPropertyNames() which is exactly what I needed (though it is oddly not const).