chore: normalize formatting for workers

This commit is contained in:
Cory Dransfeldt 2024-10-19 19:53:31 -07:00
parent 2f6cfbe7ae
commit 2cd835d31b
No known key found for this signature in database
14 changed files with 879 additions and 604 deletions

View file

@ -1,10 +1,14 @@
const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim()
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(', ')
}
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(", ");
};