Categorize port numbers by semantics.
- Helps you screen user input.
- Identify port ranges by name.
- Can tell you if it is possible to start a server.
npm install port-type --save
Get it into your program.
const portType = ;
Identify the type of port you are working with, as a lowercase string.
portType; // => "system"
But why type all that and still have to do a strict equality check? Fuggedaboutit.
portType; // => true
There are other types, too.
const port = 4444;portType; // => falseportType; // => trueportType; // => false
Still wondering what these are exactly? They are simple number ranges, which determine how different sets of ports should be used. You can get the definition of each range, too.
portTyperangesystemmin; // => 1portTyperangeregisteredmax; // => 49151
Eventually you will want to determine if it is even remotely possible or sensible to try to listen on a port.
const port = 80;portType; // => false on Windows, true everywhere elseportType; // => true on Windows, false everywhere else unless running as root
Isn't that warm and cozy? Just look at it.
See our contributing guidelines for more details.
- Fork it.
- Make a feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
Go make something, dang it.