@fruitsjs/util
Version:
Useful utilities and tools for building Fruits Eco-Blockchain applications
25 lines (22 loc) • 884 B
text/typescript
/** @ignore */
/** @internal */
/** @module util */
// https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
// @ts-ignore
if (!String.prototype.padStart) {
// @ts-ignore
String.prototype.padStart = function padStart(targetLength, padString) {
targetLength = targetLength >> 0;
padString = String(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);
}
return padString.slice(0, targetLength) + String(this);
}
};
}