2022-01-21 18:50:16 +01:00
|
|
|
/* eslint-disable */
|
2022-01-21 15:41:53 +01:00
|
|
|
const breweries = data
|
|
|
|
const totals = {}
|
2022-02-18 18:59:33 +01:00
|
|
|
for (let brewery of breweries)
|
|
|
|
{const state = brewery.state
|
|
|
|
if (totals[state] == null)
|
|
|
|
{totals[state] = 1
|
|
|
|
} else
|
|
|
|
{totals[state]++
|
2022-01-21 15:41:53 +01:00
|
|
|
}
|
|
|
|
}
|
2022-02-18 18:59:33 +01:00
|
|
|
const stateCodes =
|
|
|
|
{texas: "tx",
|
2022-01-21 15:41:53 +01:00
|
|
|
colorado: "co",
|
|
|
|
florida: "fl",
|
|
|
|
iwoa: "ia",
|
|
|
|
louisiana: "la",
|
|
|
|
california: "ca",
|
|
|
|
pennsylvania: "pa",
|
|
|
|
georgia: "ga",
|
|
|
|
"new hampshire": "nh",
|
|
|
|
virginia: "va",
|
|
|
|
michigan: "mi",
|
|
|
|
maryland: "md",
|
|
|
|
ohio: "oh",
|
|
|
|
}
|
|
|
|
const entries = Object.entries(totals)
|
2022-02-18 18:59:33 +01:00
|
|
|
return entries.map(([state, count]) =>
|
|
|
|
{stateCodes[state.toLowerCase()]
|
2022-01-21 15:41:53 +01:00
|
|
|
return { state, count, flag: "http://flags.ox3.in/svg/us/${stateCode}.svg" }
|
|
|
|
})
|