uniformize
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -15,5 +15,6 @@ declare global { | ||
* Capitalize the first letter of a string. | ||
* @param toLowerCase {boolean} If true, the string will be lowercased first. | ||
* @example "hello world".toTitle() // "Hello world" | ||
*/ | ||
toTitle(): string; | ||
toTitle(toLowerCase?: boolean): string; | ||
/** | ||
@@ -28,4 +29,5 @@ * Search for a substring in a string, standardized, trimmed and lowercased. | ||
* Capitalize the first letter of each word in a string. | ||
* toLowerCase {boolean} If true, the string will be lowercased first. | ||
*/ | ||
capitalize(): string; | ||
capitalize(toLowerCase?: boolean): string; | ||
/** | ||
@@ -44,2 +46,2 @@ * Remove emoji from a string. | ||
//biome-ignore lint/style/useExportType: This is a declaration file, no need to export as type. | ||
export {}; | ||
export { }; |
@@ -18,4 +18,5 @@ "use strict"; | ||
Object.defineProperty(String.prototype, "toTitle", { | ||
value: function() { | ||
return this.toLowerCase().charAt(0).toUpperCase() + this.slice(1); | ||
value: function(toLowerCase) { | ||
if (toLowerCase) return this.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g, (char) => char.toUpperCase()); | ||
return this.charAt(0).toUpperCase() + this.slice(1); | ||
}, | ||
@@ -25,4 +26,5 @@ enumerable: false | ||
Object.defineProperty(String.prototype, "capitalize", { | ||
value: function() { | ||
return this.toLowerCase().replace(/(^\p{L})|(\s\p{L})/giu, (char) => char.toUpperCase()); | ||
value: function(toLowerCase) { | ||
if (toLowerCase) return this.toLowerCase().replace(/(^\w{1})|(\s+\w{1})/g, (char) => char.toUpperCase()); | ||
return this.replace(/(^\p{L})|(\s\p{L})/giu, (char) => char.toUpperCase()); | ||
}, | ||
@@ -29,0 +31,0 @@ enumerable: false |
@@ -7,3 +7,3 @@ { | ||
"type": "commonjs", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"repository": { | ||
@@ -10,0 +10,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
16074
153