31 v8::Isolate::Scope isolate_scope(pIsolate);
32 v8::HandleScope scope(pIsolate);
34 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
37 v8::MaybeLocal<v8::Value> maybe_value =
38 context->Global()->Get(context, fxv8::NewStringHelper(pIsolate,
"Date"));
40 v8::Local<v8::Value> value;
41 if (!maybe_value.ToLocal(&value) || !value->IsObject())
44 v8::Local<v8::Object> obj = value.As<v8::Object>();
45 maybe_value = obj->Get(context, fxv8::NewStringHelper(pIsolate,
"parse"));
46 if (!maybe_value.ToLocal(&value) || !value->IsFunction())
49 v8::Local<v8::Function> func = value.As<v8::Function>();
50 static constexpr int argc = 1;
51 v8::Local<v8::Value> argv[argc] = {
52 fxv8::NewStringHelper(pIsolate, str.AsStringView()),
54 maybe_value = func->Call(context, context->Global(), argc, argv);
55 if (!maybe_value.ToLocal(&value) || !value->IsNumber())
58 double date = value.As<v8::Number>()->Value();
63 CJS_Runtime* pRuntime,
69 v8::LocalVector<v8::Value> result(pRuntime->GetIsolate(), nKeywords);
70 size_t size = std::min(originals.size(), nKeywords);
71 for (size_t i = 0; i < size; ++i)
72 result[i] = originals[i];
74 if (originals.size() != 1 || !originals[0]->IsObject() ||
75 originals[0]->IsArray()) {
78 result[0] = v8::Local<v8::Value>();
80 v8::Local<v8::Object> pObj = pRuntime->ToObject(originals[0]);
82 va_start(ap, nKeywords);
83 for (size_t i = 0; i < nKeywords; ++i) {
84 const char* property = va_arg(ap,
const char*);
85 v8::Local<v8::Value> v8Value = pRuntime->GetObjectProperty(pObj, property);
86 if (!v8Value->IsUndefined())