diff options
author | Sam Roberts <vieuxtech@gmail.com> | 2019-04-10 01:21:36 +0300 |
---|---|---|
committer | Sam Roberts <vieuxtech@gmail.com> | 2019-04-12 22:33:37 +0300 |
commit | 060d901f87b3d87314f8540eb02f315e2952f581 (patch) | |
tree | 53159171201703bb6d8a4e780c8624a5c6c8cbb5 /src/tcp_wrap.cc | |
parent | 7b0d8673898e65a368108264c77bccaa3e004028 (diff) |
src: replace FromJust() with Check() when possible
FromJust() is often used not for its return value, but for its
side-effects. In these cases, Check() exists, and is more clear as to
the intent. From its comment:
To be used, where the actual value of the Maybe is not needed, like
Object::Set.
See: https://github.com/nodejs/node/pull/26929/files#r269256335
PR-URL: https://github.com/nodejs/node/pull/27162
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'src/tcp_wrap.cc')
-rw-r--r-- | src/tcp_wrap.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index aedb079ccff..89c4e215bbe 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -107,7 +107,7 @@ void TCPWrap::Initialize(Local<Object> target, target->Set(env->context(), tcpString, - t->GetFunction(env->context()).ToLocalChecked()).FromJust(); + t->GetFunction(env->context()).ToLocalChecked()).Check(); env->set_tcp_constructor_template(t); // Create FunctionTemplate for TCPConnectWrap. @@ -119,7 +119,7 @@ void TCPWrap::Initialize(Local<Object> target, cwt->SetClassName(wrapString); target->Set(env->context(), wrapString, - cwt->GetFunction(env->context()).ToLocalChecked()).FromJust(); + cwt->GetFunction(env->context()).ToLocalChecked()).Check(); // Define constants Local<Object> constants = Object::New(env->isolate()); @@ -128,7 +128,7 @@ void TCPWrap::Initialize(Local<Object> target, NODE_DEFINE_CONSTANT(constants, UV_TCP_IPV6ONLY); target->Set(context, env->constants_string(), - constants).FromJust(); + constants).Check(); } @@ -353,13 +353,13 @@ Local<Object> AddressToJS(Environment* env, port = ntohs(a6->sin6_port); info->Set(env->context(), env->address_string(), - OneByteString(env->isolate(), ip)).FromJust(); + OneByteString(env->isolate(), ip)).Check(); info->Set(env->context(), env->family_string(), - env->ipv6_string()).FromJust(); + env->ipv6_string()).Check(); info->Set(env->context(), env->port_string(), - Integer::New(env->isolate(), port)).FromJust(); + Integer::New(env->isolate(), port)).Check(); break; case AF_INET: @@ -368,19 +368,19 @@ Local<Object> AddressToJS(Environment* env, port = ntohs(a4->sin_port); info->Set(env->context(), env->address_string(), - OneByteString(env->isolate(), ip)).FromJust(); + OneByteString(env->isolate(), ip)).Check(); info->Set(env->context(), env->family_string(), - env->ipv4_string()).FromJust(); + env->ipv4_string()).Check(); info->Set(env->context(), env->port_string(), - Integer::New(env->isolate(), port)).FromJust(); + Integer::New(env->isolate(), port)).Check(); break; default: info->Set(env->context(), env->address_string(), - String::Empty(env->isolate())).FromJust(); + String::Empty(env->isolate())).Check(); } return scope.Escape(info); |