|
| 1 | +#include "napi.h" |
| 2 | + |
| 3 | +using namespace Napi; |
| 4 | + |
| 5 | +static Value IsEmpty(const CallbackInfo& info) { |
| 6 | + Value value; |
| 7 | + return Boolean::New(info.Env(), value.IsEmpty()); |
| 8 | +} |
| 9 | + |
| 10 | +static Value IsUndefined(const CallbackInfo& info) { |
| 11 | + return Boolean::New(info.Env(), info[0].IsUndefined()); |
| 12 | +} |
| 13 | + |
| 14 | +static Value IsNull(const CallbackInfo& info) { |
| 15 | + return Boolean::New(info.Env(), info[0].IsNull()); |
| 16 | +} |
| 17 | + |
| 18 | +static Value IsBoolean(const CallbackInfo& info) { |
| 19 | + return Boolean::New(info.Env(), info[0].IsBoolean()); |
| 20 | +} |
| 21 | + |
| 22 | +static Value IsNumber(const CallbackInfo& info) { |
| 23 | + return Boolean::New(info.Env(), info[0].IsNumber()); |
| 24 | +} |
| 25 | + |
| 26 | +static Value IsString(const CallbackInfo& info) { |
| 27 | + return Boolean::New(info.Env(), info[0].IsString()); |
| 28 | +} |
| 29 | + |
| 30 | +static Value IsSymbol(const CallbackInfo& info) { |
| 31 | + return Boolean::New(info.Env(), info[0].IsSymbol()); |
| 32 | +} |
| 33 | + |
| 34 | +static Value IsArray(const CallbackInfo& info) { |
| 35 | + return Boolean::New(info.Env(), info[0].IsArray()); |
| 36 | +} |
| 37 | + |
| 38 | +static Value IsArrayBuffer(const CallbackInfo& info) { |
| 39 | + return Boolean::New(info.Env(), info[0].IsArrayBuffer()); |
| 40 | +} |
| 41 | + |
| 42 | +static Value IsTypedArray(const CallbackInfo& info) { |
| 43 | + return Boolean::New(info.Env(), info[0].IsTypedArray()); |
| 44 | +} |
| 45 | + |
| 46 | +static Value IsObject(const CallbackInfo& info) { |
| 47 | + return Boolean::New(info.Env(), info[0].IsObject()); |
| 48 | +} |
| 49 | + |
| 50 | +static Value IsFunction(const CallbackInfo& info) { |
| 51 | + return Boolean::New(info.Env(), info[0].IsFunction()); |
| 52 | +} |
| 53 | + |
| 54 | +static Value IsPromise(const CallbackInfo& info) { |
| 55 | + return Boolean::New(info.Env(), info[0].IsPromise()); |
| 56 | +} |
| 57 | + |
| 58 | +static Value ToBoolean(const CallbackInfo& info) { |
| 59 | + return info[0].ToBoolean(); |
| 60 | +} |
| 61 | + |
| 62 | +static Value ToNumber(const CallbackInfo& info) { |
| 63 | + return info[0].ToNumber(); |
| 64 | +} |
| 65 | + |
| 66 | +static Value ToString(const CallbackInfo& info) { |
| 67 | + return info[0].ToString(); |
| 68 | +} |
| 69 | + |
| 70 | +static Value ToObject(const CallbackInfo& info) { |
| 71 | + return info[0].ToObject(); |
| 72 | +} |
| 73 | + |
| 74 | +Object InitBasicTypesValue(Env env) { |
| 75 | + Object exports = Object::New(env); |
| 76 | + |
| 77 | + exports["isEmpty"] = Function::New(env, IsEmpty); |
| 78 | + exports["isUndefined"] = Function::New(env, IsUndefined); |
| 79 | + exports["isNull"] = Function::New(env, IsNull); |
| 80 | + exports["isBoolean"] = Function::New(env, IsBoolean); |
| 81 | + exports["isNumber"] = Function::New(env, IsNumber); |
| 82 | + exports["isString"] = Function::New(env, IsString); |
| 83 | + exports["isSymbol"] = Function::New(env, IsSymbol); |
| 84 | + exports["isArray"] = Function::New(env, IsArray); |
| 85 | + exports["isArrayBuffer"] = Function::New(env, IsArrayBuffer); |
| 86 | + exports["isTypedArray"] = Function::New(env, IsTypedArray); |
| 87 | + exports["isObject"] = Function::New(env, IsObject); |
| 88 | + exports["isFunction"] = Function::New(env, IsFunction); |
| 89 | + exports["isPromise"] = Function::New(env, IsPromise); |
| 90 | + exports["toBoolean"] = Function::New(env, ToBoolean); |
| 91 | + exports["toNumber"] = Function::New(env, ToNumber); |
| 92 | + exports["toString"] = Function::New(env, ToString); |
| 93 | + exports["toObject"] = Function::New(env, ToObject); |
| 94 | + |
| 95 | + return exports; |
| 96 | +} |
0 commit comments