Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 9, 2024 via pnpm
Package summary
Share
0
issues
1
license
1
MIT
Package created
6 Apr 2014
Version published
4 Jun 2023
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
get-port@7.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of get-port 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does get-port do?

The "get-port" package is a handy tool for retrieving an available TCP port. It provides a simple, yet effective method for acquiring an available port on the user's system. If a specified preferred port is available, the package will provide it; otherwise, it defaults to a random available port. This can prove beneficial when configuring network-related tasks where an open port is required.

How do you use get-port?

To use "get-port", start by installing it in your project using npm with the command npm install get-port. Once installed, you can import it into your JavaScript file:

import getPort from 'get-port';

After importing the package, you can use it to fetch an available port. For instance, the following lines of code will return any available port on your system:

console.log(await getPort());

If you have a preferred port, pass it in as an option:

console.log(await getPort({port: 3000}));

The tool will use your preferred port if it's available. If not, it will fall back to any available port. You can even specify an array of preferred ports:

console.log(await getPort({port: [3000, 3001, 3002]}));

It's also possible to fetch a port within a specific range using the portNumbers() helper:

import getPort, {portNumbers} from 'get-port';

console.log(await getPort({port: portNumbers(3000, 3100)}));

Keep in mind that while this package does its best to avoid race conditions within the same process, a small chance of a race condition exists if another process starts using the fetched port in between the time it's fetched and the time it's used.

Where are the get-port docs?

The comprehensive and detailed documentation for the "get-port" package can be found in its README file available at the GitHub repository: get-port. It contains all the necessary details on how to install, use, configure options, and understand possible caveats when using this package.