-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
path: replace "magic" numbers by readable constants #18654
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
// Alphabet chars. | ||
CHAR_UPPERCASE_A: 65, /*A*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: for readability it might help to change these comments to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @devdazed what about comment like this: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is probably more subjective than i realized, i'll leave it up to your judgement 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would at least put spaces and quotes around them like |
||
CHAR_LOWERCASE_A: 97, /*a*/ | ||
CHAR_UPPERCASE_Z: 90, /*Z*/ | ||
CHAR_LOWERCASE_Z: 122, /*z*/ | ||
|
||
// Non-alphabetic chars. | ||
CHAR_DOT: 46, /*.*/ | ||
CHAR_FORWARD_SLASH: 47, /*/*/ | ||
CHAR_BACKWARD_SLASH: 92, /*\*/ | ||
CHAR_COLON: 58, /*:*/ | ||
CHAR_QUESTION_MARK: 63, /*?*/ | ||
}; |
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.
Does it make sense to group the constants a little more? This module looks like it's a place where more constants could be added so maybe it makes sense to create to group them in a
character
orchar
object?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.
In general I agree but I personally think we should do that when it is time to do so instead of adding something before we need it.
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.
@kfarnung I agree with @BridgeAR. Besides, I want to refactor similar places in the codebase, so I think I'll do it next time.
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.
If we're planning to add more in the future, it makes the scope of any future change smaller and less risky. I don't have a strong feeling either way, mostly just an observation since the new file is simply
internal/constants.js
and in my experience those sorts of files get out of control before you know it.