Awesome 社区模块

@fibjs/detect-port

NPM version build status appveyor build status Test coverage David deps Known Vulnerabilities npm download

JavaScript Implementation of Port Detector

Install

1
$ npm i @fibjs/detect-port --save

Usage

1 2
const detectPort = require('@fibjs/detect-port'); const availablePort = detectPort();

or

1 2 3 4 5 6 7 8
const detectPort = require('@fibjs/detect-port'); const port = 3000; const availablePort = detectPort(port); if (availablePort === port) { console.log(`port ${port} is available!`); } else { console.log(`port ${port} is not available! Got a random available port: ${availablePort} for you.`); }

Questions & Suggestions

Please open an issue here.

License

MIT