You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some cases where just-camel-case produces subtly different results from lodash.camelcase. I noticed this while trying to replace lodash.camelcase with this library (redux-utilities/redux-actions#331).
Sadly, just-camel-case returns different results when the initial string is in all caps. I tried adding the strict option but then it failed when the initial string was already in camelcase.
It feels like strict mode should be the default (but that's not such a big deal)
Strict mode needs to check if the input string is already in camelcase
The to-camel-case lib handles this by detecting if a word is in camelCase and splits it. From there the join logic you already have would work.
Many thanks for your observations and feedback Grady. Yeah, I made those decisions consciously, knowing that they differ from lodash etc., but believing that was a more accurate interpretation of the camel case definitions I could find.
However I think you're probably right, it would be more practical to make it behave more like lodash etc. as this has become the de facto standard.
Thanks for your suggestion, I'll use it as the basis for a 'fix' (that will become a new major version) and I think I will get rid of the strict option.
I'm a bit under the weather at the moment, but when I'm ready I plan to use you suggestions but with a few changes
try to include non-english characters in the camel case and splitter regex
change the camel case tester to expect a lower case letter at the start
try to make to code more compact for minimal bytes.
Feel free to put up a PR if you get to it first
Thanks again!
just-camel-case@4.0.2 fixes these issues. I've dropped the strict option requirement and it now gives very similar results to lodash and passes your tests.
There are some cases where just-camel-case produces subtly different results from lodash.camelcase. I noticed this while trying to replace lodash.camelcase with this library (redux-utilities/redux-actions#331).
I made a quick comparison: https://repl.it/@heygrady/camelcase
Sadly, just-camel-case returns different results when the initial string is in all caps. I tried adding the
strict
option but then it failed when the initial string was already in camelcase.The
to-camel-case
lib handles this by detecting if a word is in camelCase and splits it. From there the join logic you already have would work.Here (https://repl.it/@heygrady/just-camel-case) is a naiive combination of the logic from to-camel-case with what just-camel-case does:
The text was updated successfully, but these errors were encountered: