Closed fc closed 1 year ago
What would expect the second case to camelize to?
This is what I was thinking:
volume_3d
-> volume3d
volume3d
-> volume3D
That's the only way I can imagine it working while still allowing a way to reverse it to its original form but certainly this seems like it could break something but can't think of other possiblities.
Seems inconsistent. I'm :-1:.
In your two examples, you have two different conventions: snake_case
and lowercase
. That's like expecting myvariable
to somehow automatically camel-case to myVariable
.
volume3D
in snake_case is volume_3d
volume3D
in lowercase is volume3d
Seems to reverse correctly to me.
Some context... using decamelize
right now converts volume3D
to volume3_d
.
Am I right to assume that calling decamelize
should revert the string to its original camelcased form?
My specific use case is:
I get an API result that contains an object with a property volume_3d
but on the frontend I want all keys of the objects to be volume3d
(or volume3D
), and if I am submitting back to the backend which expects the snakecase format, I want to just decamelize that volume3d
to volume_3d
but right now that does not work.
The conversion to/from camel-case is not stable and I don't think it's feasible or even ideal to do so. I think the solution here is to document in both readme's that you cannot assume stability both ways.
Hi. I'v got same problems:
Expected: b2b_registration_request -> b2bRegistrationRequest Received: b2b_registration_request -> b2BRegistrationRequest
Most other same libs works as expected, but we use camelcase-keys
package which use this package.
Libs examples:
> require('to-camel-case')('b2b_registration_request')
'b2bRegistrationRequest'
> require('to-snake-case')('b2bRegistrationRequest')
'b2b_registration_request'
> require('decamelize')('b2bRegistrationRequest')
'b2b_registration_request'
I have the same issue
var camelcaseKeys = require("camelcase")
camelcaseKeys('uses_log4j');
//=> usesLog4J
Why after number makes upper case the following character? The result migth be usesLog4j
Expected: b2b_registration_request -> b2bRegistrationRequest
I agree. That should be fixed. PR welcome.
Hey @sindresorhus, I open PR-112 to be able to handle the b2b_registration_request issue. Is this what you were looking for?
How to reproduce:
this operates under the assumption that decamelizing should return the string to its original decamelized version but I'm not sure how that would be possible for strings in this format.