Skip to content

Instantly share code, notes, and snippets.

@yuriploc
Created August 5, 2017 22:49
Show Gist options
  • Save yuriploc/472528fd7e15cd36f567ea04640d961e to your computer and use it in GitHub Desktop.
Save yuriploc/472528fd7e15cd36f567ea04640d961e to your computer and use it in GitHub Desktop.
normalizePort, from expressjs
function normalizePort(val) {
const port = parseInt(val, 10)
if (isNaN(port)) {
return val
}
if (port >= 0) {
return port
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment