Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2020-12-15 22:52:17 +0300
committerJames M Snell <jasnell@gmail.com>2021-01-03 23:58:09 +0300
commit28fe1ef63512acd40cfd1dd15918db494c92f45f (patch)
treefb65e10e0c966e2484a3f2151870738499d575b7 /src/pipe_wrap.cc
parent7cfa1bee418696c1c97c1f2466520ab4f4cc8791 (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/pipe_wrap.cc')
-rw-r--r--src/pipe_wrap.cc14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc
index 1396395463d..7ec3c66a78b 100644
--- a/src/pipe_wrap.cc
+++ b/src/pipe_wrap.cc
@@ -43,7 +43,6 @@ using v8::Int32;
using v8::Local;
using v8::MaybeLocal;
using v8::Object;
-using v8::String;
using v8::Value;
MaybeLocal<Object> PipeWrap::Instantiate(Environment* env,
@@ -69,8 +68,6 @@ void PipeWrap::Initialize(Local<Object> target,
Environment* env = Environment::GetCurrent(context);
Local<FunctionTemplate> t = env->NewFunctionTemplate(New);
- Local<String> pipeString = FIXED_ONE_BYTE_STRING(env->isolate(), "Pipe");
- t->SetClassName(pipeString);
t->InstanceTemplate()
->SetInternalFieldCount(StreamBase::kInternalFieldCount);
@@ -87,20 +84,13 @@ void PipeWrap::Initialize(Local<Object> target,
env->SetProtoMethod(t, "fchmod", Fchmod);
- target->Set(env->context(),
- pipeString,
- t->GetFunction(env->context()).ToLocalChecked()).Check();
+ env->SetConstructorFunction(target, "Pipe", t);
env->set_pipe_constructor_template(t);
// Create FunctionTemplate for PipeConnectWrap.
auto cwt = BaseObject::MakeLazilyInitializedJSTemplate(env);
cwt->Inherit(AsyncWrap::GetConstructorTemplate(env));
- Local<String> wrapString =
- FIXED_ONE_BYTE_STRING(env->isolate(), "PipeConnectWrap");
- cwt->SetClassName(wrapString);
- target->Set(env->context(),
- wrapString,
- cwt->GetFunction(env->context()).ToLocalChecked()).Check();
+ env->SetConstructorFunction(target, "PipeConnectWrap", cwt);
// Define constants
Local<Object> constants = Object::New(env->isolate());