index.js 243 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 10 export default function addLeadingZeros(number, targetLength) { var sign = number < 0 ? '-' : ''; var output = Math.abs(number).toString(); while (output.length < targetLength) { output = '0' + output; } return sign + output; }