String format 확장 제거

This commit is contained in:
2021-08-27 03:53:15 +09:00
parent 34258475f5
commit 90340c5be8
9 changed files with 41 additions and 44 deletions
+12
View File
@@ -48,6 +48,18 @@ declare global {
}
}
/**
* {0}, {1}, {2}형태로 포맷해주는 함수
* NOTE: TypeScript declare 충돌로 인해 우회 정의
*/
(String.prototype as unknown as {format:(...args:(string|number)[])=>string}).format = function(this:string, ...args){
return this.replace(/{(\d+)}/g, function (match, number) {
return (typeof args[number] != 'undefined') ? args[number].toString() : match;
});
};
window.escapeHtml = escapeHtml;
window.mb_strwidth = mb_strwidth;
window.isBrightColor = isBrightColor;