-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add port-sniffer by OperKH #28
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of recursion. Please below my comments.
process.exit(0); | ||
} | ||
|
||
function getParamsFromArguments () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function has too much responsibility. Although it is called "getParamsFromArguments", it actually not only gets the parameters, but also processes them. I suggest to split it into several functions.
This might not be a case for this small program, but usually argument parsing is reused and thus should not contain any specific logic.
}); | ||
socket.on('timeout', function () { | ||
socket.destroy(); | ||
reject(new Error('timeout')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that in terms of this program timeout is not an error, but expected behavior for closed port. Your solution is ok, but to me it looks cleaner to resolve the Promise with boolean value (true
for open ports and false
for closed ports). This way you don't need to have empty catch
block.
I've read
./README.md
and./CODE_QUALITY.md
carefully.The code is checked by npm run lint:js --fix` and linter reported no errors.
The code is submitted in its own sub-directory and in a dedicated feature branch.
Please, review.