0.0.1 • Published 9 years ago

openports v0.0.1

Weekly downloads
19
License
MIT
Repository
github
Last release
9 years ago

openports

Find multiple open ports.

Installation

npm install --save openports

Usage

/**
 * Returns n open ports. Uses port 0 for port discovery, and binds to all ports
 * prior to releasing them to help avoid race conditions. Accepts an optional
 * callback, otherwise it returns a promise.
 *
 * @param   {int}      n    Number of ports to open
 * @param   {function} [fn] Optional callback to invoke
 * @returns {Promise}  An array of port numbers
 */

Example

var openports = require('openports');

openports(1, function(err, ports) {
  console.log(ports); // [12345]
});

openports(2).then(function(ports) {
  console.log(ports); // [12345, 12346]
});