Open Styx11 opened 2 years ago
Hey guys, brilliant module! But I ran into a few problems when I used it
here is my test code:
const humps = require('humps') const formatTestStr = (target, result) => `Test case: ${target}, result: ${result}` console.log(formatTestStr('Raw_Message', humps.decamelize('Raw_Message'))) console.log(formatTestStr('raw_Message', humps.decamelize('raw_Message'))) console.log(formatTestStr('Raw_message', humps.decamelize('Raw_message'))) console.log(formatTestStr('raw_Message_Another', humps.decamelize('raw_Message_Another')))
and it comes out:
Test case: Raw_Message, result: raw__message // <- oops Test case: raw_Message, result: raw__message // <- oops Test case: Raw_message, result: raw_message Test case: raw_Message_Another, result: raw__message__another // <- oops
as you can see, there is an unexpected underscore when target string is an underscore case string and _ is followed by an upper case character
underscore case
_
2.0.1
just turn underscore case string into lower case
well then, I think change-case is a better choice
Desc
Hey guys, brilliant module! But I ran into a few problems when I used it
here is my test code:
and it comes out:
as you can see, there is an unexpected underscore when target string is an
underscore case
string and_
is followed by an upper case characterVersion
2.0.1
Expect
just turn
underscore case
string into lower case