在 Node.js C++ N-API 中迭代 Napi::Object 属性(键)

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

我在使用 c++ n-api api 时遇到问题,我已经查看了文档 here,但我没有找到一种方法来迭代 Napi::Object。我一定是遗漏了一些东西,因为这在 JavaScript 中是可能的,所以在 C++ API.

中一定是可能的

如何在 Napi::Object.

中列出或迭代键(属性)

Google 出现在 https://nodejs.github.io/node-addon-api/ 的 Doxygen 文档似乎是 out-of-date。

查看的正确位置是 Node.js Github 存储库 https://github.com/nodejs/node-addon-api/blob/master/napi.h

查看正确的 header 版本,Napi::Object 有一个函数 GetPropertyNames() 这正是我需要的(尽管奇怪的是它不是 const)。