code: function isFree(port, opt_host) {
    return new Promise((resolve, reject) => {
      let server = net.createServer().on('error', function(e) {
        if (e.code === 'EADDRINUSE') {
          resolve(false);
        } else {
          reject(e);
        }
      });
  
      server.listen(port, opt_host, function() {
        server.close(() => resolve(true));
      });
    });
  }
docs: Tests if a port is free.
  @param {number} port The port to test.
  @param {string=} opt_host The bound host to test the {@code port} against.
  Defaults to {@code INADDR_ANY}.
  @return {!Promise<boolean>} A promise that will resolve with whether the port
  is free.