简体   繁体   中英

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

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.

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM