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
[FEATURE] Add toSnakeCase #321
Conversation
|
@kriadmin Good edge case I missed, however that might be sub-optimal. Maybe there's a regex way to deal with that? |
I already knew about this edge case from about a month ago. This can't be dealt with regex(according to me). Checking if it starts with '-' is the only solution(acc to me). |
Alright, I'll not merge and wait for a couple more opinions until tomorrow. If there's no better (i.e. more elegant) way, this is a pretty decent fix nonetheless, so I'll update and merge later. |
@Chalarangelo I also see that the last test returns this: |
@iamsoorena Good catch, I'll see if I can figure out a way to update it tomorrow, then. Feel free to apply fixes if you figure it out before I do! |
checks if the uppercase charcater is preceded by another character
@kriadmin @Chalarangelo |
@elderhsouza Try this text "I have Lot's of _Spaces" |
I just made some updates, replacing multiple spaces/hyphens/underscores with a single underscore, this should now work pretty much fine. Can you find any more edge-cases we might have missed? |
What about |
@kriadmin I see how you would want to handle this but I don't think that any library would handle it properly anyways. |
@Chalarangelo Lodash returns |
@Chalarangelo See the second comment here lodash/lodash#561 by jdalton |
@kriadmin That would require a lot of code to handle just one (or a select few) cases. If it doesn't make the snippet very difficult to read, I'm not against it, however I am not sure I can implement this on my own. Suggestions are welcome, I'm marking this snippet |
Converts a string to snakecase.
Description
Lodash[ACTION] #100 -> https://lodash.com/docs/4.17.4#snakeCase
What does your PR belong to?
Types of changes
Checklist: