diff options
author | James M Snell <jasnell@gmail.com> | 2020-12-15 22:52:17 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2021-01-03 23:58:09 +0300 |
commit | 28fe1ef63512acd40cfd1dd15918db494c92f45f (patch) | |
tree | fb65e10e0c966e2484a3f2151870738499d575b7 /src/node_serdes.cc | |
parent | 7cfa1bee418696c1c97c1f2466520ab4f4cc8791 (diff) |
src: reduce duplicated boilerplate with new env utility fn
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/36536
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_serdes.cc')
-rw-r--r-- | src/node_serdes.cc | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/node_serdes.cc b/src/node_serdes.cc index b51d315989c..879253f9bc2 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -475,13 +475,8 @@ void Initialize(Local<Object> target, "_setTreatArrayBufferViewsAsHostObjects", SerializerContext::SetTreatArrayBufferViewsAsHostObjects); - Local<String> serializerString = - FIXED_ONE_BYTE_STRING(env->isolate(), "Serializer"); - ser->SetClassName(serializerString); ser->ReadOnlyPrototype(); - target->Set(env->context(), - serializerString, - ser->GetFunction(env->context()).ToLocalChecked()).Check(); + env->SetConstructorFunction(target, "Serializer", ser); Local<FunctionTemplate> des = env->NewFunctionTemplate(DeserializerContext::New); @@ -503,14 +498,9 @@ void Initialize(Local<Object> target, env->SetProtoMethod(des, "readDouble", DeserializerContext::ReadDouble); env->SetProtoMethod(des, "_readRawBytes", DeserializerContext::ReadRawBytes); - Local<String> deserializerString = - FIXED_ONE_BYTE_STRING(env->isolate(), "Deserializer"); des->SetLength(1); des->ReadOnlyPrototype(); - des->SetClassName(deserializerString); - target->Set(env->context(), - deserializerString, - des->GetFunction(env->context()).ToLocalChecked()).Check(); + env->SetConstructorFunction(target, "Deserializer", des); } } // anonymous namespace |