index.js 243 B

12345678910
  1. export default function addLeadingZeros(number, targetLength) {
  2. var sign = number < 0 ? '-' : '';
  3. var output = Math.abs(number).toString();
  4. while (output.length < targetLength) {
  5. output = '0' + output;
  6. }
  7. return sign + output;
  8. }