PascalCase and camelCase helpers don't work on themselves
nickav opened this issue · 3 comments
It would be nice to use pascalcase, camelcase and a new snakecase helper to transform between all three. Currently:
pascalcase('FooBar') # returns 'Foobar'
camelcase('fooBar') # returns 'foobar'
You would expect pascalcase(pascalcase) to still be pascalcase and so on
It would be nice to use pascalcase, camelcase and a new snakecase helper to transform between all three
It kind of does that, but maybe not consistently(?) and obviously it's missing some cases.
Thanks for reporting this, want to do a pr?
there's this library that implements these
That lib looks like it does everything except for handle casing lol.
First, we need to decide on the tradeoff we're going to make. Do we want reliable accuracy, or less code and fewer dependencies?
My point is that many libraries handle casing, but to do it correctly is actually much more complicated than it might seem, and if we're going to decide that we don't care about 100% accuracy then we have nothing to gain by using an external lib that obviously doesn't do it correctly anyway. We can just "do it incorrectly" here, without the dependency.
If we're going to use deps, I personally would prefer to use a library that does it correctly. The best lib I've seen for this is https://github.com/blakeembrey/change-case. If we go that route, then I'd also prefer that we implement helpers for all of the cases in that library (since the methods would be available anyway).
just my 2c
edit: fwiw I meant "completely", not "correctly". Since we're talking about a number of helpers here.