2016-01-26 15:12:41 +01:00
|
|
|
'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) {
|
2016-03-16 04:46:53 +01:00
|
|
|
if ((typeof port !== 'number' && typeof port !== 'string') ||
|
|
|
|
(typeof port === 'string' && port.trim().length === 0))
|
2016-01-26 15:12:41 +01:00
|
|
|
return false;
|
2016-03-16 04:46:53 +01:00
|
|
|
return +port === (+port >>> 0) && port <= 0xFFFF;
|
2016-01-26 15:12:41 +01:00
|
|
|
}
|
2016-03-16 00:34:19 +01:00
|
|
|
|
2017-02-15 23:29:00 +01:00
|
|
|
module.exports = {
|
2017-05-18 20:19:21 +02:00
|
|
|
isLegalPort,
|
|
|
|
normalizedArgsSymbol: Symbol('normalizedArgs')
|
2017-02-15 23:29:00 +01:00
|
|
|
};
|