padleft.js
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];
}
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];
}
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 ] ; }
pads some side
pads some side