-
Notifications
You must be signed in to change notification settings - Fork 181
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
Bugfix/snake camel dash #114
Bugfix/snake camel dash #114
Conversation
*/ | ||
export const camel = (str: string): string => { | ||
const parts = str?.split(/[\.\-\s_]/).map(x => x.toLowerCase()) ?? [] | ||
const parts = str | ||
?.replace(/([A-Z])+/g, capitalize) |
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 did not know you could use a function as the replacement argument 🤯 ❤️
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.
yes, that's pretty cool, in my service we use it this way with maps, filters, etc... It makes the code more readable
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.
Thanks @MarlonPassos-git so much for this PR, I like the simple fix and how consistent it is with the existing code. I also ❤️ the added tests!
This PR has been published 🚀 to npm in version |
Thanks so much for the fix! Just want to point out that the usage of toLowercase may not function as expected when some other locale is used as input. I believe one should prefer the usage of to LocaleLowerCase to get 100% accuracy, but as the two functions mostly produce the same results I'm not sure if you feel it is worth the change and possibly additional optional parameter. |
@wouter-leistra thanks for pointing this out, I've never had a need to work with i8 before so I've never used locale. I'm down to add it or would accept a pr. |
* test(string - snake function): has camelCase and dash * feat(snake): now works with camal case * docs(snake): add jsdoc with word with camalCase * test(dast): handle with camel case and dash * feat(dash): now works with camal case * docs(dash): add jsdoc with word with camalCase * test(camel): a word in camel case should remain in camel case * feat(camel): now works with camal case * test(camel): a word in camel case should remain in camel case * release v8.0.1 Co-authored-by: marlon Felipe Passos <[email protected]> Co-authored-by: Ray Epps <[email protected]>
Description
Please provide a detailed description of the changes and the intent behind them :)
Checklist
package.json
has been bumped according to the changes made and standard semantic versioning rulesResolves
#96
I saw an interesting thread about things that are not 100% compared to lodash. I made this pr to fix these "bug"