From 6316c9a0f8b83cba1c60995eafc61d3a84c198f2 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 27 Jun 2017 13:29:58 -0400 Subject: [PATCH] n-api: add napi_delete_element() Refs: https://github.com/nodejs/node/issues/13924 PR-URL: https://github.com/nodejs/node/pull/13949 Reviewed-By: Jason Ginchereau --- doc/api/n-api.md | 22 +++++++++++++++ src/node_api.cc | 20 +++++++++++++ src/node_api.h | 4 +++ test/addons-napi/test_array/test.js | 11 ++++++++ test/addons-napi/test_array/test_array.c | 36 ++++++++++++++++++++++++ 5 files changed, 93 insertions(+) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 078d9642e246f7..052c6cbdb4c394 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -2400,6 +2400,27 @@ Returns `napi_ok` if the API succeeded. This API returns if the Object passed in has an element at the requested index. +#### *napi_delete_element* + +```C +napi_status napi_delete_element(napi_env env, + napi_value object, + uint32_t index, + bool* result); +``` + +- `[in] env`: The environment that the N-API call is invoked under. +- `[in] object`: The object to query. +- `[in] index`: The index of the property to delete. +- `[out] result`: Whether the element 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 specified `index` from `object`. + #### *napi_define_properties*