get-unused-port-in-list

Run through a list of TCP ports and return one that is not busy

Usage no npm install needed!

<script type="module">
  import getUnusedPortInList from 'https://cdn.skypack.dev/get-unused-port-in-list';
</script>

README

get-unused-port-in-list

Stability: 2 - Stable

npm Build Status

Description

Run through a list of TCP ports and return one that is not busy

Usage

require('get-unused-port-in-list')([7000, 8000, 9000])
  .then((unusedPort) => {
    // unusedPort port is free (first caught)
  })
  .catch(() => {
    // All ports are busy
  })