@@ -169,6 +169,10 @@ Maybe<bool> SerializerContext::WriteHostObject(Isolate* isolate,
169
169
170
170
void SerializerContext::New (const FunctionCallbackInfo<Value>& args) {
171
171
Environment* env = Environment::GetCurrent (args);
172
+ if (!args.IsConstructCall ()) {
173
+ return THROW_ERR_CONSTRUCT_CALL_REQUIRED (
174
+ env, " Class constructor Serializer cannot be invoked without 'new'" );
175
+ }
172
176
173
177
new SerializerContext (env, args.This ());
174
178
}
@@ -319,6 +323,10 @@ MaybeLocal<Object> DeserializerContext::ReadHostObject(Isolate* isolate) {
319
323
320
324
void DeserializerContext::New (const FunctionCallbackInfo<Value>& args) {
321
325
Environment* env = Environment::GetCurrent (args);
326
+ if (!args.IsConstructCall ()) {
327
+ return THROW_ERR_CONSTRUCT_CALL_REQUIRED (
328
+ env, " Class constructor Deserializer cannot be invoked without 'new'" );
329
+ }
322
330
323
331
if (!args[0 ]->IsArrayBufferView ()) {
324
332
return node::THROW_ERR_INVALID_ARG_TYPE (
@@ -470,6 +478,7 @@ void Initialize(Local<Object> target,
470
478
Local<String> serializerString =
471
479
FIXED_ONE_BYTE_STRING (env->isolate (), " Serializer" );
472
480
ser->SetClassName (serializerString);
481
+ ser->ReadOnlyPrototype ();
473
482
target->Set (env->context (),
474
483
serializerString,
475
484
ser->GetFunction (env->context ()).ToLocalChecked ()).Check ();
@@ -496,6 +505,8 @@ void Initialize(Local<Object> target,
496
505
497
506
Local<String> deserializerString =
498
507
FIXED_ONE_BYTE_STRING (env->isolate (), " Deserializer" );
508
+ des->SetLength (1 );
509
+ des->ReadOnlyPrototype ();
499
510
des->SetClassName (deserializerString);
500
511
target->Set (env->context (),
501
512
deserializerString,
0 commit comments