Skip to content

Commit 7c7f5c8

Browse files
rickyescodebytere
authored andcommitted
net: refactor check for Windows
PR-URL: #33497 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 6f8b7a8 commit 7c7f5c8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/net.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ const { kTimeout } = require('internal/timers');
119119
const DEFAULT_IPV4_ADDR = '0.0.0.0';
120120
const DEFAULT_IPV6_ADDR = '::';
121121

122+
const isWindows = process.platform === 'win32';
123+
122124
function noop() {}
123125

124126
function getFlags(ipv6Only) {
@@ -336,8 +338,7 @@ function Socket(options) {
336338
this[async_id_symbol] = this._handle.getAsyncId();
337339

338340
if ((fd === 1 || fd === 2) &&
339-
(this._handle instanceof Pipe) &&
340-
process.platform === 'win32') {
341+
(this._handle instanceof Pipe) && isWindows) {
341342
// Make stdout and stderr blocking on Windows
342343
err = this._handle.setBlocking(true);
343344
if (err)
@@ -1028,7 +1029,7 @@ function lookupAndConnect(self, options) {
10281029
hints: options.hints || 0
10291030
};
10301031

1031-
if (process.platform !== 'win32' &&
1032+
if (!isWindows &&
10321033
dnsopts.family !== 4 &&
10331034
dnsopts.family !== 6 &&
10341035
dnsopts.hints === 0) {
@@ -1227,7 +1228,7 @@ function createServerHandle(address, port, addressType, fd, flags) {
12271228
assert(!address && !port);
12281229
} else if (port === -1 && addressType === -1) {
12291230
handle = new Pipe(PipeConstants.SERVER);
1230-
if (process.platform === 'win32') {
1231+
if (isWindows) {
12311232
const instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES);
12321233
if (!NumberIsNaN(instances)) {
12331234
handle.setPendingInstances(instances);
@@ -1711,7 +1712,7 @@ Server.prototype.unref = function() {
17111712
let _setSimultaneousAccepts;
17121713
let warnSimultaneousAccepts = true;
17131714

1714-
if (process.platform === 'win32') {
1715+
if (isWindows) {
17151716
let simultaneousAccepts;
17161717

17171718
_setSimultaneousAccepts = function(handle) {

0 commit comments

Comments
 (0)