default-port

Get the default port for a protocol.

Usage no npm install needed!

<script type="module">
  import defaultPort from 'https://cdn.skypack.dev/default-port';
</script>

README

default-port

Get the default port for a protocol.

Why?

  • Translate user input to server config.
  • Useful defaults for connecting to services.
  • Determine if you can strip the port from a URL.

Install

npm install default-port --save

Usage

Get it into your program.

const defaultPort = require('default-port');

Retrieve the default port for a protocol, as a lowercase string.

const port = defaultPort(
    'https',  // protocol you want to check
);
console.log(port);  // => 443

Contributing

See our contributing guidelines for more details.

  1. Fork it.
  2. Make a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

License

MPL-2.0 © Seth Holladay

Go make something, dang it.