-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Added normalize transform option to normalize string spaces #217
base: master
Are you sure you want to change the base?
Changes from 1 commit
c35990f
d7be11c
15d1763
2103376
08fe5eb
b227a26
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ type TransformName = | |
| "toLowerCase" | ||
| "toUpperCase" | ||
| "toEnumCase" | ||
| "normalize" | ||
|
||
interface TransformConfig { | ||
hash: Record<string, string | undefined> | ||
|
@@ -26,6 +27,7 @@ const transform: {[key in TransformName]: Transform} = { | |
toLowerCase: (s) => s.toLowerCase(), | ||
toUpperCase: (s) => s.toUpperCase(), | ||
toEnumCase: (s, cfg) => cfg?.hash[configKey(s)] || s, | ||
normalize: (s) => s.replace(/\s\s+/g, " "), | ||
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. why not just 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. ...or 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. because 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. also, pretty much the regex 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. The performance of replacing 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. check my latest commits, i have resolved these issues and also added |
||
} | ||
|
||
const getDef: (() => CodeKeywordDefinition) & { | ||
|
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.
The name is too generic for what it does... Possible alternative -
trimInner
(and should it not replace tabs too?).Any better ideas?
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.
word
trim
means to remove space, this just removes extra spaces, its not a bad idea though to also include remove spaces completely, withtrimInner
and come up with a better name for this one likenormalizeSpaces
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.
let's please not conflate two different things into on PR.
I don't know the use case for removing all inner spaces tbh, normalizeSpaces is ok though.
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.
ok, will separate the other one in a different PR, will make another commit today
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.
review my latest commit