Revert "lib: use helper for readability"

This reverts commit 937bbc5571.

PR-URL: https://github.com/nodejs/node/pull/40741
Fixes: https://github.com/nodejs/node/issues/40693
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
Darshan Sen authored and Danielle Adams committed 2022-01-31 22:53:54 -05:00
1 parent 48e2b60c44
commit 4bcff4c5f8
1 file changed
+25 -14
+25 -14
View File
@@ -22,41 +22,52 @@ const kCurrentWriteRequest = Symbol('kCurrentWriteRequest');
const kCurrentShutdownRequest = Symbol('kCurrentShutdownRequest');
const kPendingShutdownRequest = Symbol('kPendingShutdownRequest');
function checkReusedHandle(self) {
let socket = self[owner_symbol];
if (socket.constructor.name === 'ReusedHandle')
socket = socket.handle;
return socket;
}
function isClosing() {
const socket = checkReusedHandle(this);
let socket = this[owner_symbol];
if (socket.constructor.name === 'ReusedHandle') {
socket = socket.handle;
}
return socket.isClosing();
}
function onreadstart() {
const socket = checkReusedHandle(this);
let socket = this[owner_symbol];
if (socket.constructor.name === 'ReusedHandle') {
socket = socket.handle;
}
return socket.readStart();
}
function onreadstop() {
const socket = checkReusedHandle(this);
let socket = this[owner_symbol];
if (socket.constructor.name === 'ReusedHandle') {
socket = socket.handle;
}
return socket.readStop();
}
function onshutdown(req) {
const socket = checkReusedHandle(this);
let socket = this[owner_symbol];
if (socket.constructor.name === 'ReusedHandle') {
socket = socket.handle;
}
return socket.doShutdown(req);
}
function onwrite(req, bufs) {
const socket = checkReusedHandle(this);
let socket = this[owner_symbol];
if (socket.constructor.name === 'ReusedHandle') {
socket = socket.handle;
}
return socket.doWrite(req, bufs);
}