chore: normalize formatting
This commit is contained in:
parent
01ed2ac3b3
commit
2f6cfbe7ae
61 changed files with 921 additions and 743 deletions
|
@ -1,27 +1,28 @@
|
|||
export const shuffleArray = array => {
|
||||
const shuffled = [...array]
|
||||
export const shuffleArray = (array) => {
|
||||
const shuffled = [...array];
|
||||
for (let i = shuffled.length - 1; i > 0; i--) {
|
||||
let j = Math.floor(Math.random() * (i + 1))
|
||||
let temp = shuffled[i]
|
||||
shuffled[i] = shuffled[j]
|
||||
shuffled[j] = temp
|
||||
let j = Math.floor(Math.random() * (i + 1));
|
||||
let temp = shuffled[i];
|
||||
shuffled[i] = shuffled[j];
|
||||
shuffled[j] = temp;
|
||||
}
|
||||
return shuffled
|
||||
}
|
||||
return shuffled;
|
||||
};
|
||||
|
||||
export const regionNames = new Intl.DisplayNames(['en'], { type: 'region' })
|
||||
export const regionNames = new Intl.DisplayNames(["en"], { type: "region" });
|
||||
|
||||
export const getCountryName = (countryCode) => regionNames.of(countryCode.trim()) || countryCode.trim()
|
||||
export const getCountryName = (countryCode) =>
|
||||
regionNames.of(countryCode.trim()) || countryCode.trim();
|
||||
|
||||
export const parseCountryField = (countryField) => {
|
||||
if (!countryField) return null
|
||||
if (!countryField) return null;
|
||||
|
||||
const delimiters = [',', '/', '&', 'and']
|
||||
let countries = [countryField]
|
||||
const delimiters = [",", "/", "&", "and"];
|
||||
let countries = [countryField];
|
||||
|
||||
delimiters.forEach(delimiter => {
|
||||
countries = countries.flatMap(country => country.split(delimiter))
|
||||
})
|
||||
delimiters.forEach((delimiter) => {
|
||||
countries = countries.flatMap((country) => country.split(delimiter));
|
||||
});
|
||||
|
||||
return countries.map(getCountryName).join(', ')
|
||||
}
|
||||
return countries.map(getCountryName).join(", ");
|
||||
};
|
||||
|
|
Reference in a new issue