-
Notifications
You must be signed in to change notification settings - Fork 191
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
Handle nonprint chars #963
Conversation
Add progress messages to LGTM download option. (github#960)
const codes: { [key: string]: any } = { | ||
'\n': 'U+000A', | ||
'\b': 'U+2084', | ||
'\0': 'U+0000' | ||
}; |
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.
Can you move this out of the function to the module level scope? This way, the constant doesn't need to be recreated on each invocation.
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.
And presumably, you will be able to add more replacements in the future?
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.
You can explicitly add all of the control char mappings described here #584 (comment).
if ( | ||
typeof v === 'string' | ||
|| typeof v === 'number' | ||
|| typeof v === 'boolean' | ||
) { | ||
return <span>{v.toString()}</span>; | ||
const text = v.toString(); |
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.
Not a big fan of one char variable names. Can you rename it to something like rawValue
. I know this code was already, but it's never too late to make improvements. :)
for (const char in codes) { | ||
if (char === newVal[i]) { | ||
newVal[i] = codes[char]; | ||
} | ||
} |
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.
There's something simpler you can do here. You don't need to loop.
for (const char in codes) { | |
if (char === newVal[i]) { | |
newVal[i] = codes[char]; | |
} | |
} | |
newVal[i] = codes[newVal[i]] || newVal[i]; |
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.
Small suggestion about the change log and then 🚢 .
Co-authored-by: Andrew Eisenberg <[email protected]>
Resolves #584
Checklist
@github/docs-content-codeql
has been cc'd in all issues for UI or other user-facing changes made by this pull request.