{"size": 892, "ext": "js", "max_stars_repo_path": "frontend/src/utils/NumberUtils.js", "max_stars_repo_name": "KnowYourDeFi/knowyourdefi.github.io", "max_stars_repo_stars_event_min_datetime": "2021-07-18T12:33:01.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-13T05:58:04.000Z", "max_issues_repo_path": "frontend/src/utils/NumberUtils.js", "max_issues_repo_name": "KnowYourDeFi/knowyourdefi.github.io", "max_issues_repo_issues_event_min_datetime": "2021-07-27T08:39:30.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-27T08:39:30.000Z", "max_forks_repo_path": "frontend/src/utils/NumberUtils.js", "max_forks_repo_name": "KnowYourDeFi/knowyourdefi.github.io", "max_forks_repo_forks_event_min_datetime": "2021-07-05T14:48:59.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-14T05:56:47.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 2, "avg_line_length": 28.7741935484, "max_line_length": 89, "alphanum_fraction": 0.6233183857}

export function numberWithCommas(x) {
  const parts = parseFloat(x).toString().split(".");
  parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",")
  return parts.join(".")
}

const symbols = ["", "k", "m", "b", "t", "q"]
export const abbreviateNumber = (number, fixed = 1) => {

    // what tier? (determines symbol)
    var tier = Math.log10(Math.abs(number)) / 3 | 0

    // if zero, we don't need a suffix
    if(tier === 0) return number;
    // get suffix and determine scale
    tier = Math.min(tier, symbols.length - 1)
    var suffix = symbols[tier];
    var scale = Math.pow(10, tier * 3);

    // scale the number
    var scaled = number / scale;

    // format number and add suffix, use the parseFloat function to remove trailing zeros
    return parseFloat(scaled.toFixed(fixed)) + suffix;
}

export function isNumeric(value) {
  return !isNaN(value - parseFloat(value));
}
