{"size": 725, "ext": "js", "max_stars_repo_path": "common/money.js", "max_stars_repo_name": "auramo/bowman", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "common/money.js", "max_issues_repo_name": "auramo/bowman", "max_issues_repo_issues_event_min_datetime": "2020-12-30T20:46:04.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T09:05:50.000Z", "max_forks_repo_path": "common/money.js", "max_forks_repo_name": "auramo/bowman", "max_forks_repo_forks_event_min_datetime": "2019-09-30T02:14:01.000Z", "max_forks_repo_forks_event_max_datetime": "2019-09-30T02:14:01.000Z"}
{"max_stars_count": null, "max_issues_count": 5, "max_forks_count": 1, "avg_line_length": 30.2083333333, "max_line_length": 82, "alphanum_fraction": 0.635862069}
const centsToString = amountCents => {
  const euros = Math.floor(amountCents / 100)
  //const cents = amountCents % 100 ? `,${amountCents % 100}` : ''
  const cents = amountCents % 100 ? `,${amountCents % 100}` : ',00'
  return `${euros}${cents}`
}

const moneyRegex = /(^\$?[\d]+),?(\d*?$)/

const stringToCents = euroString => {
  if (!euroString) return null
  const result = euroString.match(moneyRegex)
  if (result) {
    const rawCents = result[2] || '0'
    if (rawCents.length > 2) return null
    const cents = rawCents.length === 2 ? Number(rawCents) : Number(rawCents) * 10
    const euros = Number(result[1])
    return cents + euros * 100
  }
  return null
}

module.exports = { centsToString, stringToCents }
