mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
359 B
12 lines
359 B
9 years ago
|
'use strict';
|
||
|
|
||
|
module.exports = { isLegalPort };
|
||
|
|
||
|
// 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 === 'string' && port.trim() === '')
|
||
|
return false;
|
||
|
return +port === (port >>> 0) && port >= 0 && port <= 0xFFFF;
|
||
|
}
|