import type { Country } from '../../data/countries'; // Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare const filterCountriesByIso3 = (countries: readonly Country[], iso3Codes: readonly string[]) => { const iso3CodesSet = new Set(iso3Codes); return countries.filter((country) => !iso3CodesSet.has(country.iso3)); }; /** * Removes the countries sepecified in the second param * * @param countries list of country metadata objects * @param disabledCountries list of iso3 country codes to remove from the list */ export const excludeCountries = ( countries: readonly Country[], disabledCountries: readonly string[], ) => { return disabledCountries.length > 0 ? filterCountriesByIso3(countries, disabledCountries) : countries; };