Added opt-out trim to capitalize util.
This commit is contained in:
parent
c7fac575e4
commit
51ffcb5be7
|
@ -1,10 +1,12 @@
|
|||
'use strict';
|
||||
|
||||
function capitalize(string) {
|
||||
return string
|
||||
function capitalize(string, trim = true) {
|
||||
const capitalized = string
|
||||
.split(/\s/)
|
||||
.map(component => `${component.charAt(0).toUpperCase()}${component.slice(1)}`)
|
||||
.join(' ');
|
||||
|
||||
return trim ? capitalized.trim() : capitalized;
|
||||
}
|
||||
|
||||
module.exports = capitalize;
|
||||
|
|
Loading…
Reference in New Issue