mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
879d6663ea
A module `assertPort` in `lib/internal/net.js` is not used anymore. Refs: https://github.com/nodejs/node/pull/11667 PR-URL: https://github.com/nodejs/node/pull/11812 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
15 lines
421 B
JavaScript
15 lines
421 B
JavaScript
'use strict';
|
|
|
|
// Check that the port number is not NaN when coerced to a number,
|
|
// is an integer and that it falls within the legal range of port numbers.
|
|
function isLegalPort(port) {
|
|
if ((typeof port !== 'number' && typeof port !== 'string') ||
|
|
(typeof port === 'string' && port.trim().length === 0))
|
|
return false;
|
|
return +port === (+port >>> 0) && port <= 0xFFFF;
|
|
}
|
|
|
|
module.exports = {
|
|
isLegalPort
|
|
};
|