Skip to content

Commit 08951a1

Browse files
danbevevanlucas
authored andcommitted
src: replace IsConstructCalls with lambda
I've added a deprecation notice as the functions are public, but not sure if this is correct or the format of the deprecation notice. PR-URL: #12533 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent f0b5afe commit 08951a1

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/stream_base.h

-8
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ class ShutdownWrap : public ReqWrap<uv_shutdown_t>,
5353
Wrap(req_wrap_obj, this);
5454
}
5555

56-
static void NewShutdownWrap(const v8::FunctionCallbackInfo<v8::Value>& args) {
57-
CHECK(args.IsConstructCall());
58-
}
59-
6056
static ShutdownWrap* from_req(uv_shutdown_t* req) {
6157
return ContainerOf(&ShutdownWrap::req_, req);
6258
}
@@ -83,10 +79,6 @@ class WriteWrap: public ReqWrap<uv_write_t>,
8379

8480
size_t self_size() const override { return storage_size_; }
8581

86-
static void NewWriteWrap(const v8::FunctionCallbackInfo<v8::Value>& args) {
87-
CHECK(args.IsConstructCall());
88-
}
89-
9082
static WriteWrap* from_req(uv_write_t* req) {
9183
return ContainerOf(&WriteWrap::req_, req);
9284
}

src/stream_wrap.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ void StreamWrap::Initialize(Local<Object> target,
3838
Local<Context> context) {
3939
Environment* env = Environment::GetCurrent(context);
4040

41+
auto is_construct_call_callback =
42+
[](const FunctionCallbackInfo<Value>& args) {
43+
CHECK(args.IsConstructCall());
44+
};
4145
Local<FunctionTemplate> sw =
42-
FunctionTemplate::New(env->isolate(), ShutdownWrap::NewShutdownWrap);
46+
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
4347
sw->InstanceTemplate()->SetInternalFieldCount(1);
4448
sw->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"));
4549
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ShutdownWrap"),
4650
sw->GetFunction());
4751

4852
Local<FunctionTemplate> ww =
49-
FunctionTemplate::New(env->isolate(), WriteWrap::NewWriteWrap);
53+
FunctionTemplate::New(env->isolate(), is_construct_call_callback);
5054
ww->InstanceTemplate()->SetInternalFieldCount(1);
5155
ww->SetClassName(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"));
5256
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "WriteWrap"),

0 commit comments

Comments
 (0)