0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-11-08 13:48:40 +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:
Christiano Becker 2018-12-03 11:30:22 -02:00
parent 85097c1d68
commit d36aa6c9d5

View File

@ -484,6 +484,15 @@ V8JS_METHOD(require)
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) {
v8::Local<v8::Object> newobj = zval_to_v8js(&module_code, isolate)->ToObject(isolate->GetEnteredContext()).ToLocalChecked();