From 9c6804c1dff0203751dd01da4e226e19de636a71 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 3 Jul 2017 15:06:46 -0400 Subject: [PATCH] n-api: add napi_has_own_property() Refs: https://github.com/nodejs/node/issues/13925 PR-URL: https://github.com/nodejs/node/pull/14063 Reviewed-By: Anna Henningsen Reviewed-By: Franziska Hinkelmann --- doc/api/n-api.md | 24 +++++++++++++++ src/node_api.cc | 21 +++++++++++++ src/node_api.h | 4 +++ test/addons-napi/test_object/test.js | 34 ++++++++++++++++++++++ test/addons-napi/test_object/test_object.c | 29 ++++++++++++++++++ 5 files changed, 112 insertions(+) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 16d64d3d5fad70..ac66f27035c7e1 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2298,6 +2298,29 @@ Returns `napi_ok` if the API succeeded. This API attempts to delete the `key` own property from `object`. +#### *napi_has_own_property* + +```C +napi_status napi_has_own_property(napi_env env, + napi_value object, + napi_value key, + bool* result); +``` + +- `[in] env`: The environment that the N-API call is invoked under. +- `[in] object`: The object to query. +- `[in] key`: The name of the own property whose existence to check. +- `[out] result`: Whether the own property exists on the object or not. + +Returns `napi_ok` if the API succeeded. + +This API checks if the Object passed in has the named own property. `key` must +be a string or a Symbol, or an error will be thrown. N-API will not perform any +conversion between data types. + + #### *napi_set_named_property*