From c584343217202763a2f870ce17112cf0c4b08b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 5 Dec 2019 19:12:09 -0400 Subject: [PATCH] Add GetPropertyNames, HasOwnProperty, Delete (#615) Fixes: https://github.com/nodejs/node-addon-api/issues/614 PR-URL: https://github.com/nodejs/node-addon-api/pull/615 Fixes: https://github.com/nodejs/node-addon-api/issues/614 Reviewed-By: NickNaso Reviewed-By: Michael Dawson --- doc/object.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/doc/object.md b/doc/object.md index ddc97f7f1..c92165aeb 100644 --- a/doc/object.md +++ b/doc/object.md @@ -101,6 +101,22 @@ While the value must be any of the following types: - `bool` - `double` +### Delete() + +```cpp +bool Napi::Object::Delete(____ key); +``` +- `[in] key`: The name of the property to delete. + +Deletes the property associated with the given key. Returns `true` if the property was deleted. + +The `key` can be any of the following types: +- `napi_value` +- [`Napi::Value`](value.md) +- `const char *` +- `const std::string &` +- `uint32_t` + ### Get() ```cpp @@ -171,6 +187,29 @@ void finalizeCallback(Napi::Env env, T* data, Hint* hint); ``` where `data` and `hint` are the pointers that were passed into the call to `AddFinalizer()`. +### GetPropertyNames() +```cpp +Napi::Array Napi::Object::GetPropertyNames() const; +``` + +Returns the names of the enumerable properties of the object as a [`Napi::Array`](basic_types.md#array) of strings. +The properties whose key is a `Symbol` will not be included. + +### HasOwnProperty() +```cpp +bool Napi::Object::HasOwnProperty(____ key); const +``` +- `[in] key` The name of the property to check. + +Returns a `bool` that is *true* if the object has an own property named `key` and *false* otherwise. + +The key can be any of the following types: +- `napi_value` +- [`Napi::Value`](value.md) +- `const char*` +- `const std::string&` +- `uint32_t` + ### DefineProperty() ```cpp