-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
22 lines (21 loc) · 818 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function () {
"use strict";
if (String.prototype.format == undefined) {
let string_format_V2_0_2 = function () {
let args = arguments;
let cnt = 0;
return this.match(/{(\d+)}/g) == null && this.match(/{}/g) != null ?
this.replace(/{}/g, (match) => {
return typeof args[cnt] != 'undefined' ? args[cnt++] : match;
}) :
this.replace(/{(\d+)}/g, (match, number) => {
return typeof args[number] != 'undefined' ? args[number] : match;
});
};
String.prototype.format = string_format_V2_0_2;
} else {
if (String.prototype.format.name != 'string_format_V2_0_2') {
throw 'String.prototype.format defined.';
}
}
})();