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