Gazebo_simulation-Frontend/node_modules/detect-port-alt
Riddhi Dave f4870cd530 simulator page updates 2020-12-22 09:59:14 -05:00
..
.vscode React files 2020-12-21 10:29:31 -05:00
bin React files 2020-12-21 10:29:31 -05:00
lib React files 2020-12-21 10:29:31 -05:00
node_modules simulator page updates 2020-12-22 09:59:14 -05:00
.eslintignore React files 2020-12-21 10:29:31 -05:00
.eslintrc React files 2020-12-21 10:29:31 -05:00
CONTRIBUTING.md React files 2020-12-21 10:29:31 -05:00
HISTORY.md React files 2020-12-21 10:29:31 -05:00
LICENSE React files 2020-12-21 10:29:31 -05:00
README.md React files 2020-12-21 10:29:31 -05:00
appveyor.yml React files 2020-12-21 10:29:31 -05:00
index.js React files 2020-12-21 10:29:31 -05:00
logo.png React files 2020-12-21 10:29:31 -05:00
package.json simulator page updates 2020-12-22 09:59:14 -05:00

README.md

logo


NPM version build status Test coverage npm download

JavaScript Implementation of Port Detector

Usage

$ npm i detect-port --save
const detect = require('detect-port');

/**
 * callback usage
 */

detect(port, (err, _port) => {
  if (err) {
    console.log(err);
  }

  if (port == _port) {
    console.log(`port: ${port} was not occupied`);
  } else {
    console.log(`port: ${port} was occupied, try port: ${_port}`);
  }
});

/**
 * for a yield syntax instead of callback function implement
 */

const co = require('co');

co(function *() {
  const _port = yield detect(port);

  if (port == _port) {
    console.log(`port: ${port} was not occupied`);
  } else {
    console.log(`port: ${port} was occupied, try port: ${_port}`);
  }
});

/**
 * use as a promise
 */

detect(port)
  .then(_port => {
    if (port == _port) {
      console.log(`port: ${port} was not occupied`);
    } else {
      console.log(`port: ${port} was occupied, try port: ${_port}`);
    }
  })
  .catch(err => {
    console.log(err);
  });

Command Line Tool

$ npm i detect-port -g

Quick Start

# get an available port randomly
$ detect

# detect pointed port
$ detect 80

# more help
$ detect --help

Authors

License

MIT