Skip to content

Commit 931a709

Browse files
committed
fix #19, add more reliable type check
1 parent 7047abf commit 931a709

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/util.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* rules:
33
* - abc-def -> abcDef
44
* - -abc-def -> AbcDef
5-
*
5+
*
66
* @param {string} value
77
* @return {string}
88
*/
@@ -16,12 +16,15 @@ exports.hyphenedToCamelCase = function hyphenedToCamelCase(value) {
1616
* rules:
1717
* - abcDef -> abc-def
1818
* - AbcDef -> -abc-def
19-
*
19+
*
2020
* @param {string} value
2121
* @return {string}
2222
*/
2323
exports.camelCaseToHyphened = function camelCaseToHyphened(value) {
2424
return value.replace(/([A-Z])/g, function(s, m) {
25-
return '-' + m.toLowerCase()
25+
if (typeof m === 'string') {
26+
return '-' + m.toLowerCase()
27+
}
28+
return m
2629
})
2730
}

0 commit comments

Comments
 (0)