mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 16:52:59 +08:00
fixed camelCase function
Added check for empty word
This commit is contained in:
parent
459ab71c45
commit
7432e01740
@ -359,7 +359,14 @@ class Utilities {
|
||||
* @param {string} string The string to transform.
|
||||
*/
|
||||
camelCase(string){
|
||||
return string.toLowerCase().trim().split(/[.\-_\s]/g).reduce((string, word) => string + word[0].toUpperCase() + word.slice(1));
|
||||
return string
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.split(/[.\-_\s]/g)
|
||||
.reduce(
|
||||
(string, word) =>
|
||||
word.length ? string + word[0].toUpperCase() + word.slice(1) : string
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -373,4 +380,4 @@ class Utilities {
|
||||
}
|
||||
}
|
||||
|
||||
export default Utilities;
|
||||
export default Utilities;
|
||||
|
Loading…
Reference in New Issue
Block a user