17 lines
550 B
TypeScript
17 lines
550 B
TypeScript
|
interface StringConstructor {
|
||
|
IsNullOrEmpty: (value: string) => boolean;
|
||
|
Format: (format: string, ...args: any[]) => string;
|
||
|
}
|
||
|
|
||
|
String.IsNullOrEmpty = function (value: string): boolean {
|
||
|
return value === undefined || value === null || value.trim() === '';
|
||
|
};
|
||
|
|
||
|
String.Format = function (format: string, ...args: any[]): string {
|
||
|
return format.replace(/{(\d+)}/g, (match, index) => {
|
||
|
let value = args[index];
|
||
|
if (value === null || value === undefined) return '';
|
||
|
return '' + value;
|
||
|
});
|
||
|
}
|