chore: worker cleanup

This commit is contained in:
Cory Dransfeldt 2024-10-18 11:44:47 -07:00
parent 8b2648f23f
commit 3aadaeb741
No known key found for this signature in database
10 changed files with 464 additions and 425 deletions

View file

@ -0,0 +1,10 @@
const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim()
export const parseCountryField = (countryField) => {
if (!countryField) return null
const delimiters = [',', '/', '&', 'and']
let countries = [countryField]
delimiters.forEach(delimiter => countries = countries.flatMap(country => country.split(delimiter)))
return countries.map(getCountryName).join(', ')
}