-
Notifications
You must be signed in to change notification settings - Fork 465
/
has_property.cc
38 lines (32 loc) · 1.26 KB
/
has_property.cc
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
32
33
34
35
36
37
38
#include "napi.h"
#include "test_helper.h"
using namespace Napi;
Value HasPropertyWithNapiValue(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
Name key = info[1].As<Name>();
return Boolean::New(
info.Env(), MaybeUnwrapOr(obj.Has(static_cast<napi_value>(key)), false));
}
Value HasPropertyWithNapiWrapperValue(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
Name key = info[1].As<Name>();
return Boolean::New(info.Env(), MaybeUnwrapOr(obj.Has(key), false));
}
Value HasPropertyWithCStyleString(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
String jsKey = info[1].As<String>();
return Boolean::New(info.Env(),
MaybeUnwrapOr(obj.Has(jsKey.Utf8Value().c_str()), false));
}
Value HasPropertyWithUint32(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
Number jsKey = info[1].As<Number>();
return Boolean::New(info.Env(),
MaybeUnwrapOr(obj.Has(jsKey.Uint32Value()), false));
}
Value HasPropertyWithCppStyleString(const CallbackInfo& info) {
Object obj = info[0].UnsafeAs<Object>();
String jsKey = info[1].As<String>();
return Boolean::New(info.Env(),
MaybeUnwrapOr(obj.Has(jsKey.Utf8Value()), false));
}