code: function pad(side, num, ch) {
    var 
      exp = `${side === 'left' ? '' : '^'}.{${num}}${side === 'right' ? '' : '$'}`,
      re = new RegExp(exp), pad = '';
    do {
      pad += ch;
    } while(pad.length < num);
    
    return re.exec( (side === 'left') ? (pad + this) : (this + pad) )[0];
  }
docs: pads some side