lib/utils.js
function checkAvailable(host, port) {
  return new Promise(function(resolve, reject) {
    const socket = new net.Socket();

    socket.on('connect', () => {
      cleanupSocket(socket);
      resolve(true);
    });

    socket.on('error', err => {
      cleanupSocket(socket);
      if (err.code !== 'ECONNREFUSED') {
        return reject(err);
      }

      resolve(false);
    });

    socket.connect({ port: port, host: host });
  });
}
function checkAvailable(host, port) {
  return new Promise(function(resolve, reject) {
    const socket = new net.Socket();

    socket.on('connect', () => {
      cleanupSocket(socket);
      resolve(true);
    });

    socket.on('error', err => {
      cleanupSocket(socket);
      if (err.code !== 'ECONNREFUSED') {
        return reject(err);
      }

      resolve(false);
    });

    socket.connect({ port: port, host: host });
  });
}
function checkAvailable ( host , port ) { return new Promise ( function ( resolve , reject ) { const socket = new net . Socket ( ) ; socket . on ( 'connect' , ( ) => { cleanupSocket ( socket ) ; resolve ( true ) ; } ) ; socket . on ( 'error' , err => { cleanupSocket ( socket ) ; if ( err . code !== 'ECONNREFUSED' ) { return reject ( err ) ; } resolve ( false ) ; } ) ; socket . connect ( { port : port , host : host } ) ; } ) ; }
Checks if a provided address is actively listening for incoming connections

@param {string} host the host to connect to
@param {number} port the port to check for availability
Checks if a provided address is actively listening for incoming connections