@lorefnon/tslog
Version:
Extensible TypeScript Logger for Node.js and Browser.
20 lines (19 loc) • 557 B
JavaScript
export function formatNumberAddZeros(value, digits = 2, addNumber = 0) {
if (value != null && isNaN(value)) {
return "";
}
value = value != null ? value + addNumber : value;
return digits === 2
? value == null
? "--"
: value < 10
? "0" + value
: value.toString()
: value == null
? "---"
: value < 10
? "00" + value
: value < 100
? "0" + value
: value.toString();
}