@@ -832,27 +832,25 @@ void Close(const FunctionCallbackInfo<Value>& args) {
832832}
833833
834834
835- // Used to speed up module loading. Returns object
836- // {string: string | undefined, containsKeys: undefined | boolean}
835+ // Used to speed up module loading. Returns an array [string, boolean]
837836static void InternalModuleReadJSON (const FunctionCallbackInfo<Value>& args) {
838837 Environment* env = Environment::GetCurrent (args);
839838 Isolate* isolate = env->isolate ();
840839 uv_loop_t * loop = env->event_loop ();
841- Local<Object> return_value = Object::New (isolate);
842840
843841 CHECK (args[0 ]->IsString ());
844842 node::Utf8Value path (isolate, args[0 ]);
845843
846844 if (strlen (*path) != path.length ()) {
847- args.GetReturnValue ().Set (return_value );
845+ args.GetReturnValue ().Set (Array::New (isolate) );
848846 return ; // Contains a nul byte.
849847 }
850848 uv_fs_t open_req;
851849 const int fd = uv_fs_open (loop, &open_req, *path, O_RDONLY, 0 , nullptr );
852850 uv_fs_req_cleanup (&open_req);
853851
854852 if (fd < 0 ) {
855- args.GetReturnValue ().Set (return_value );
853+ args.GetReturnValue ().Set (Array::New (isolate) );
856854 return ;
857855 }
858856
@@ -879,7 +877,7 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo<Value>& args) {
879877 uv_fs_req_cleanup (&read_req);
880878
881879 if (numchars < 0 ) {
882- args.GetReturnValue ().Set (return_value );
880+ args.GetReturnValue ().Set (Array::New (isolate) );
883881 return ;
884882 }
885883 offset += numchars;
@@ -916,19 +914,17 @@ static void InternalModuleReadJSON(const FunctionCallbackInfo<Value>& args) {
916914 if (0 == memcmp (s, " exports" , 7 )) break ;
917915 }
918916 }
919- return_value-> Set (
920- isolate-> GetCurrentContext (),
921- FIXED_ONE_BYTE_STRING (isolate, " string " ),
917+
918+
919+ Local<Value> return_value[] = {
922920 String::NewFromUtf8 (isolate,
923- &chars[start],
924- v8::NewStringType::kNormal ,
925- size).ToLocalChecked ()).Check ();
926-
927- return_value->Set (
928- isolate->GetCurrentContext (),
929- FIXED_ONE_BYTE_STRING (isolate, " containsKeys" ),
930- Boolean::New (isolate, p < pe ? true : false )).Check ();
931- args.GetReturnValue ().Set (return_value);
921+ &chars[start],
922+ v8::NewStringType::kNormal ,
923+ size).ToLocalChecked (),
924+ Boolean::New (isolate, p < pe ? true : false )
925+ };
926+ args.GetReturnValue ().Set (
927+ Array::New (isolate, return_value, arraysize (return_value)));
932928}
933929
934930// Used to speed up module loading. Returns 0 if the path refers to
0 commit comments