We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 68cd565 commit 4522666Copy full SHA for 4522666
lib/utilities.js
@@ -10,7 +10,13 @@
10
var _hyphenPattern = /-(.)/g;
11
12
function camelCase(string) {
13
- return string.replace(_hyphenPattern, function(_, character) {
+ if (typeof string !== 'string') { // null is an object
14
+ throw new TypeError('First argument must be a string');
15
+ }
16
+ if(string.indexOf('-') < 0) {
17
+ return string;
18
19
+ return string.toLowerCase().replace(_hyphenPattern, function(_, character) {
20
return character.toUpperCase();
21
});
22
}
0 commit comments