mirror of
https://github.com/phpv8/v8js.git
synced 2024-12-22 17:31:53 +00:00
Update v8js_methods.cc
* require() method: check when Module Loader returns an array (ex: require on a .json file) and map to array to JavaScript
This commit is contained in:
parent
85097c1d68
commit
d36aa6c9d5
@ -485,6 +485,15 @@ V8JS_METHOD(require)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Z_TYPE(module_code) == IS_ARRAY) {
|
||||||
|
v8::Local<v8::Value> newarray = zval_to_v8js(&module_code, isolate);
|
||||||
|
c->modules_loaded[normalised_module_id].Reset(isolate, newarray);
|
||||||
|
info.GetReturnValue().Set(newarray);
|
||||||
|
|
||||||
|
efree(normalised_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(Z_TYPE(module_code) == IS_OBJECT) {
|
if(Z_TYPE(module_code) == IS_OBJECT) {
|
||||||
v8::Local<v8::Object> newobj = zval_to_v8js(&module_code, isolate)->ToObject(isolate->GetEnteredContext()).ToLocalChecked();
|
v8::Local<v8::Object> newobj = zval_to_v8js(&module_code, isolate)->ToObject(isolate->GetEnteredContext()).ToLocalChecked();
|
||||||
c->modules_loaded[normalised_module_id].Reset(isolate, newobj);
|
c->modules_loaded[normalised_module_id].Reset(isolate, newobj);
|
||||||
|
Loading…
Reference in New Issue
Block a user