22 lines
356 B
JavaScript
Raw Normal View History

2024-08-24 20:48:14 +02:00
var space = require('to-space-case')
/**
* Export.
*/
module.exports = toCapitalCase
/**
* Convert a `string` to capital case.
*
* @param {String} string
* @return {String}
*/
function toCapitalCase(string) {
return space(string).replace(/(^|\s)(\w)/g, function (matches, previous, letter) {
return previous + letter.toUpperCase()
})
}