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