Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

find-free-ports

1.1.0 • Public • Published

This is a very small package that allows developers to find free ports on the local system. Unlike most other "find-free-port" utilities, this library allows scanning for multiple free ports at once, making sure that there are no doubles in the result.

This library has been benchmarked and parallelises the port checks using a customisable number of workers for optimal performance.

🔍 Found an issue? Please let me know in the issue tracker and we'll get it fixed ASAP.

npm i find-free-ports

Usage

const findFreePorts = require('find-free-ports');
 
async function init() {
  const [a, b, c, d] = await findFreePorts(4);
  // now do something interesting with the new ports ...
}

Development

We use TypeScript to check for human mistakes.

tsc --watch

You can run the tests with the following command:

npm test

⚠️ The tests may use a lot of resources so make sure your computer is up for the task. Also, due to race conditios with other applications that cannot be avoided, the tests may falsly fail or succeed in rare cases. Be sure to double-check any changes you make.

Similar Packages

License

The MIT License

Install

npm i find-free-ports

DownloadsWeekly Downloads

216

Version

1.1.0

License

MIT

Unpacked Size

11.7 kB

Total Files

10

Last publish

Collaborators

  • avatar