diff --git a/polyfill.js b/polyfill.js new file mode 100644 index 0000000..bce9725 --- /dev/null +++ b/polyfill.js @@ -0,0 +1,19 @@ +if (!String.prototype.padStart) { + String.prototype.padStart = function padStart(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 padString.slice(0, targetLength) + String(this); + } + } +} + +Number.prototype.toHex = function () { + return this.toString(16).padStart(2, "0") +} diff --git a/util.js b/util.js new file mode 100644 index 0000000..e69de29