File: global_object_delete_property.cc

package info (click to toggle)
node-addon-api 8.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,248 kB
  • sloc: cpp: 15,431; javascript: 5,631; ansic: 157; makefile: 7
file content (31 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "napi.h"
#include "test_helper.h"

using namespace Napi;

Value DeletePropertyWithCStyleStringAsKey(const CallbackInfo& info) {
  Object globalObject = info.Env().Global();
  String key = info[0].UnsafeAs<String>();
  return Boolean::New(
      info.Env(), MaybeUnwrap(globalObject.Delete(key.Utf8Value().c_str())));
}

Value DeletePropertyWithCppStyleStringAsKey(const CallbackInfo& info) {
  Object globalObject = info.Env().Global();
  String key = info[0].UnsafeAs<String>();
  return Boolean::New(info.Env(),
                      MaybeUnwrap(globalObject.Delete(key.Utf8Value())));
}

Value DeletePropertyWithInt32AsKey(const CallbackInfo& info) {
  Object globalObject = info.Env().Global();
  Number key = info[0].UnsafeAs<Number>();
  return Boolean::New(info.Env(),
                      MaybeUnwrap(globalObject.Delete(key.Uint32Value())));
}

Value DeletePropertyWithNapiValueAsKey(const CallbackInfo& info) {
  Object globalObject = info.Env().Global();
  Name key = info[0].UnsafeAs<Name>();
  return Boolean::New(info.Env(), MaybeUnwrap(globalObject.Delete(key)));
}