mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
lib: use helper for readability
Used an extra `checkReusedHandle()` helper function to increase readability. PR-URL: https://github.com/nodejs/node/pull/39649 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
@@ -22,52 +22,41 @@ const kCurrentWriteRequest = Symbol('kCurrentWriteRequest');
|
||||
const kCurrentShutdownRequest = Symbol('kCurrentShutdownRequest');
|
||||
const kPendingShutdownRequest = Symbol('kPendingShutdownRequest');
|
||||
|
||||
function isClosing() {
|
||||
let socket = this[owner_symbol];
|
||||
function checkReusedHandle(self) {
|
||||
let socket = self[owner_symbol];
|
||||
|
||||
if (socket.constructor.name === 'ReusedHandle') {
|
||||
if (socket.constructor.name === 'ReusedHandle')
|
||||
socket = socket.handle;
|
||||
}
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
function isClosing() {
|
||||
const socket = checkReusedHandle(this);
|
||||
|
||||
return socket.isClosing();
|
||||
}
|
||||
|
||||
function onreadstart() {
|
||||
let socket = this[owner_symbol];
|
||||
|
||||
if (socket.constructor.name === 'ReusedHandle') {
|
||||
socket = socket.handle;
|
||||
}
|
||||
const socket = checkReusedHandle(this);
|
||||
|
||||
return socket.readStart();
|
||||
}
|
||||
|
||||
function onreadstop() {
|
||||
let socket = this[owner_symbol];
|
||||
|
||||
if (socket.constructor.name === 'ReusedHandle') {
|
||||
socket = socket.handle;
|
||||
}
|
||||
const socket = checkReusedHandle(this);
|
||||
|
||||
return socket.readStop();
|
||||
}
|
||||
|
||||
function onshutdown(req) {
|
||||
let socket = this[owner_symbol];
|
||||
|
||||
if (socket.constructor.name === 'ReusedHandle') {
|
||||
socket = socket.handle;
|
||||
}
|
||||
const socket = checkReusedHandle(this);
|
||||
|
||||
return socket.doShutdown(req);
|
||||
}
|
||||
|
||||
function onwrite(req, bufs) {
|
||||
let socket = this[owner_symbol];
|
||||
|
||||
if (socket.constructor.name === 'ReusedHandle') {
|
||||
socket = socket.handle;
|
||||
}
|
||||
const socket = checkReusedHandle(this);
|
||||
|
||||
return socket.doWrite(req, bufs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user