add string extension for capitalize string

This commit is contained in:
Mylloon 2022-07-24 23:45:39 +02:00
parent b3d8755b7d
commit 9ed2138bab
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

16
src/modules/string.ts Normal file
View file

@ -0,0 +1,16 @@
export {};
declare global {
// Declarations
interface String {
/**
* Returns a copy of the string with the first letter capitalized.
*/
capitalize(): string,
}
}
/** Capitalize definition */
String.prototype.capitalize = function(this: string) {
return this[0].toUpperCase() + this.substring(1);
};