2018-10-26 20:54:03 +08:00
|
|
|
/* eslint-disable */
|
2018-11-19 18:46:26 +08:00
|
|
|
|
2019-12-11 22:07:22 +08:00
|
|
|
// Any IE only polyfill should be moved in discourse-internet-explorer plugin
|
2019-01-04 01:03:01 +08:00
|
|
|
|
2019-04-29 22:58:17 +08:00
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/flags#Polyfill
|
2019-12-11 22:07:22 +08:00
|
|
|
// IE and EDGE
|
2019-04-29 22:58:17 +08:00
|
|
|
if (RegExp.prototype.flags === undefined) {
|
|
|
|
Object.defineProperty(RegExp.prototype, "flags", {
|
|
|
|
configurable: true,
|
|
|
|
get: function() {
|
|
|
|
return this.toString().match(/[gimsuy]*$/)[0];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-14 17:54:39 +08:00
|
|
|
// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
|
|
|
|
if (!String.prototype.padStart) {
|
|
|
|
String.prototype.padStart = function padStart(targetLength, padString) {
|
|
|
|
targetLength = targetLength >> 0; //truncate if number, or convert non-number to 0;
|
|
|
|
padString = String(typeof padString !== "undefined" ? padString : " ");
|
|
|
|
if (this.length >= targetLength) {
|
|
|
|
return String(this);
|
|
|
|
} else {
|
|
|
|
targetLength = targetLength - this.length;
|
|
|
|
if (targetLength > padString.length) {
|
|
|
|
padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
|
|
|
|
}
|
|
|
|
return padString.slice(0, targetLength) + String(this);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd
|
|
|
|
if (!String.prototype.padEnd) {
|
|
|
|
String.prototype.padEnd = function padEnd(targetLength, padString) {
|
|
|
|
targetLength = targetLength >> 0; //floor if number or convert non-number to 0;
|
|
|
|
padString = String(typeof padString !== "undefined" ? padString : " ");
|
|
|
|
if (this.length > targetLength) {
|
|
|
|
return String(this);
|
|
|
|
} else {
|
|
|
|
targetLength = targetLength - this.length;
|
|
|
|
if (targetLength > padString.length) {
|
|
|
|
padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
|
|
|
|
}
|
|
|
|
return String(this) + padString.slice(0, targetLength);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-10-26 20:54:03 +08:00
|
|
|
/* eslint-enable */
|