summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2017-06-27 13:29:58 -0400
committercjihrig <cjihrig@gmail.com>2017-06-30 17:08:51 -0400
commitf803e77b1e2347dbce9d8098f3b6e231f4ce5fcd (patch)
treef75980ab6073ce282168d359a9a0ec8fd0625cc7 /src
parent9e5a2118cc15c63088837ce9424e844084d07633 (diff)
downloadandroid-node-v8-f803e77b1e2347dbce9d8098f3b6e231f4ce5fcd.tar.gz
android-node-v8-f803e77b1e2347dbce9d8098f3b6e231f4ce5fcd.tar.bz2
android-node-v8-f803e77b1e2347dbce9d8098f3b6e231f4ce5fcd.zip
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 <jasongin@microsoft.com>
Diffstat (limited to 'src')
-rw-r--r--src/node_api.cc20
-rw-r--r--src/node_api.h4
2 files changed, 24 insertions, 0 deletions
diff --git a/src/node_api.cc b/src/node_api.cc
index 18ff7b64e4..c237e78031 100644
--- a/src/node_api.cc
+++ b/src/node_api.cc
@@ -1139,6 +1139,26 @@ napi_status napi_get_element(napi_env env,
return GET_RETURN_STATUS(env);
}
+napi_status napi_delete_element(napi_env env,
+ napi_value object,
+ uint32_t index,
+ bool* result) {
+ NAPI_PREAMBLE(env);
+
+ v8::Isolate* isolate = env->isolate;
+ v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Object> obj;
+
+ CHECK_TO_OBJECT(env, context, obj, object);
+ v8::Maybe<bool> delete_maybe = obj->Delete(context, index);
+ CHECK_MAYBE_NOTHING(env, delete_maybe, napi_generic_failure);
+
+ if (result != NULL)
+ *result = delete_maybe.FromMaybe(false);
+
+ return GET_RETURN_STATUS(env);
+}
+
napi_status napi_define_properties(napi_env env,
napi_value object,
size_t property_count,
diff --git a/src/node_api.h b/src/node_api.h
index a184094360..58222e7431 100644
--- a/src/node_api.h
+++ b/src/node_api.h
@@ -250,6 +250,10 @@ NAPI_EXTERN napi_status napi_get_element(napi_env env,
napi_value object,
uint32_t index,
napi_value* result);
+NAPI_EXTERN napi_status napi_delete_element(napi_env env,
+ napi_value object,
+ uint32_t index,
+ bool* result);
NAPI_EXTERN napi_status
napi_define_properties(napi_env env,
napi_value object,