mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-09-16 20:49:06 +00:00
21 lines
386 B
JavaScript
21 lines
386 B
JavaScript
module.exports = function(str, options) {
|
|
options = Object.assign(
|
|
{
|
|
lowercaseRestOfWord: false
|
|
},
|
|
options
|
|
);
|
|
|
|
return str
|
|
.split(" ")
|
|
.map(function(word) {
|
|
return (
|
|
word.substr(0, 1).toUpperCase() +
|
|
(options.lowercaseRestOfWord
|
|
? word.substr(1).toLowerCase()
|
|
: word.substr(1))
|
|
);
|
|
})
|
|
.join(" ");
|
|
};
|