zero-fill.js (352B)
1export default function zeroFill(number, targetLength, forceSign) { 2 var absNumber = '' + Math.abs(number), 3 zerosToFill = targetLength - absNumber.length, 4 sign = number >= 0; 5 return ( 6 (sign ? (forceSign ? '+' : '') : '-') + 7 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + 8 absNumber 9 ); 10}