jam-cloud/jam-ui/node_modules/detect-port-alt
Nuwan 23d1ece36d fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
..
.vscode fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
bin fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
lib fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
node_modules fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
.eslintignore fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
.eslintrc fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
CONTRIBUTING.md fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
HISTORY.md fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
LICENSE fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
README.md fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
appveyor.yml fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
index.js fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
logo.png fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30
package.json fixing controller tests after upgradeing to rails5 2022-02-15 16:27:07 +05:30

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