Skip to content

Commit

Permalink
Add polyfils
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Feb 22, 2020
1 parent 830767d commit db12528
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions 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")
}
Empty file added util.js
Empty file.

0 comments on commit db12528

Please sign in to comment.