β Check if a number is a valid port respecting the IANA Service Name and Transport Protocol Port Number Registry. Because I always forget if the last is 65535? 65534? xD.
π Ping me on Twitter
if you like this project
β Install latest Node.js stable version (or LTS) and then:
npm i -g is-port
π More examples are provided in the test folder.
import { isPort } from "is-port";
console.log(isPort(5)); // true
console.log(isPort(10000000)); // false
π If you wanted to help please take a look to this file.
π Full method definition.
Checks if the passed number is a valid port.
-
port
(number) - Candidate to check. -
valid
(boolean) - Result of the validation.