JSPM

getport

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2291
  • Score
    100M100P100Q114322F
  • License BSD

Find an open port to listen on.

Package Exports

  • getport

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (getport) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

getport

npm install getport

Find an open port to listen on.

`getport(function (e, port) {})``

var getport = require('getport')
getport(function (e, p) {
  if (e) throw e
  server.listen(p)
})

Note: getport uses a TCP client to check the ports and see if anyone has bound to them. If you do not have permission to bind to a port you may still get an error.

getport(start, function (e, port) {})

getport(5000, function (e, p) {
  if (e) throw e
  assert.equal(5000, p)
})

getport(start, end, function (e, port) {})

getport(6000, 5999, function (e, p) {
  assert.ok(e)
})