function padNumber(number, width, precision) {
  const numberString =
    precision !== undefined ? number.toFixed(precision) : '' + number;
  let decimal = numberString.indexOf('.');
  decimal = decimal === -1 ? numberString.length : decimal;
  return decimal > width
    ? numberString
    : new Array(1 + width - decimal).join('0') + numberString;
}
@param {number} number Number to be formatted
@param {number} width The desired width
@param {number} [precision] Precision of the output string (i.e. number of decimal places)
@return {string} Formatted string