From 80cf25a8a5a5e2adf6cf94522c601b80b4319b30 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Mon, 26 Jun 2017 14:31:55 -0400 Subject: [PATCH] n-api: add napi_delete_property() Fixes: https://github.com/nodejs/node/issues/13924 Backport-PR-URL: https://github.com/nodejs/node/pull/19447 PR-URL: https://github.com/nodejs/node/pull/13934 Reviewed-By: Michael Dawson Reviewed-By: James M Snell Reviewed-By: Jason Ginchereau --- doc/api/n-api.md | 23 +++++++++++ src/node_api.cc | 22 +++++++++++ src/node_api.h | 4 ++ test/addons-napi/test_object/test.js | 44 ++++++++++++++++++++++ test/addons-napi/test_object/test_object.c | 26 +++++++++++++ 5 files changed, 119 insertions(+) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 5c6654f97cfdd0..831a02cf3dfa82 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2276,6 +2276,28 @@ Returns `napi_ok` if the API succeeded. This API checks if the Object passed in has the named property. +#### *napi_delete_property* + +```C +napi_status napi_delete_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 property to delete. +- `[out] result`: Whether the property deletion succeeded or not. `result` can +optionally be ignored by passing `NULL`. + +Returns `napi_ok` if the API succeeded. + +This API attempts to delete the `key` own property from `object`. + + #### *napi_set_named_property*