/**
 * Copied from https://github.com/behnammodi/polyfill/blob/master/string.polyfill.js
 *
 * String.padStart()
 * version 1.0.1
 * Feature	        Chrome  Firefox Internet Explorer   Opera	Safari	Edge
 * Basic support	  57   	  51      (No)	              44   	10      15
 * -------------------------------------------------------------------------------
 */

if (!String.prototype.padStart) {
    Object.defineProperty(String.prototype, 'padStart', {
        configurable: true,
        writable: true,
        value: function (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);
            }
        },
    });
}
