-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
path: replace "magic" numbers by readable constants #18654
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
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*/ | ||
|
||
| 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
characterorcharobject?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.
Uh oh!
There was an error while loading. Please reload this page.
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.jsand in my experience those sorts of files get out of control before you know it.