Matheus Sampaio Queiroga
772443cc58
Some checks failed
Test / test_cross (16.x) (push) Failing after 2m15s
Test / test_cross (18.x) (push) Failing after 2m48s
Test / test_cross (19.x) (push) Failing after 2m47s
Test / test_cross (17.x) (push) Failing after 2m51s
Test / test_cross (20.x) (push) Failing after 1m34s
Test / test_cross (21.x) (push) Failing after 1m21s
28 lines
1.1 KiB
C++
28 lines
1.1 KiB
C++
#include <napi.h>
|
|
#include "g.h"
|
|
|
|
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
exports.Set("Test Date", Napi::Date::New(env, time(nullptr) * 1000));
|
|
exports.Set("Test", Napi::String::New(env, "Test obj"));
|
|
exports.Set("bigint", Napi::BigInt::New(env, (int64_t)(time(nullptr) * 1000)));
|
|
exports.Set("function", Napi::Function::New(env, [](const Napi::CallbackInfo &info) -> Napi::Value {
|
|
const Napi::Array args = Napi::Array::New(info.Env());
|
|
for (unsigned int i = 0; i < info.Length(); i++) {
|
|
const Napi::Value val = info[i];
|
|
if (val.IsString()) args.Set(i, "string");
|
|
else if (val.IsNumber()) args.Set(i, "number");
|
|
else if (val.IsBigInt()) args.Set(i, "bigint");
|
|
else if (val.IsBoolean()) args.Set(i, "bol");
|
|
else if (val.IsArray()) args.Set(i, "array");
|
|
else if (val.IsFunction()) args.Set(i, "function");
|
|
else if (val.IsObject()) args.Set(i, "object");
|
|
else if (val.IsNull()) args.Set(i, "null");
|
|
else if (val.IsUndefined()) args.Set(i, "undefined");
|
|
else args.Set(i, "unknown");
|
|
}
|
|
return args;
|
|
}));
|
|
return exports;
|
|
}
|
|
NODE_API_MODULE(addon, Init);
|