Skip to content

Instantly share code, notes, and snippets.

@anurag-roy
Created May 26, 2021 13:13
Show Gist options
  • Save anurag-roy/1510e12f426fb812dda6056d4c066032 to your computer and use it in GitHub Desktop.
Save anurag-roy/1510e12f426fb812dda6056d4c066032 to your computer and use it in GitHub Desktop.
console.clear();
const carrierArray = [
"T-Mobile - 3G *(US)*",
"T-Mobile - 4G *(US)*",
"Verizon Wireless - 3G *(US)*",
"Verizon Wireless - 4G *(US)*",
"Sprint - 3G *(US)*",
"Sprint - 4G *(US)*",
"AT&T - 3G *(US)*",
"AT&T - 4G *(US)*",
"Bell - 3G *(CA)*",
"Bell - 4G *(CA)*",
"Rogers - 3G *(CA)*",
"Rogers - 4G *(CA)*",
"Telus - 3G *(CA)*",
"Telus - 4G *(CA)*",
"Freedom Mobile - 3G *(CA)*",
"Freedom Mobile - 4G *(CA)*",
"Vodafone - 3G *(UK)* & *(IE)*",
"Vodafone - 4G *(UK)* & *(IE)*",
"Three - 3G *(UK)* & *(IE)*",
"Three - 4G *(UK)* & *(IE)*",
"O2 - 3G *(UK)* & *(IE)*",
"O2 - 4G *(UK)* & *(IE)*",
"EE - 3G *(UK)* & *(IE)*",
"EE - 4G *(UK)* & *(IE)*",
"Deutsche Telekom - 3G *(DE)*",
"Deutsche Telekom - 4G *(DE)*",
"Vodafone - 3G *(DE)*",
"Vodafone - 4G *(DE)*",
"O2 (Telefónica) -3G *(DE)*",
"O2 (Telefónica) - 4G *(DE)*",
"Orange - 3G *(FR)*",
"Orange - 4G *(FR)*",
"SFR - 3G *(FR)*",
"SFR - 4G *(FR)*",
"Bouygues - 3G *(FR)*",
"Bouygues - 4G *(FR)*",
"Free - 3G *(FR)*",
"Free - 4G *(FR)*",
];
const countryArray = [
"US",
"CA",
"UK",
"IE",
"DE",
"FR",
] as const;
const countryCodeToNameMapping = {
"US": "United States",
"CA": "Canada",
"UK": "United Kingdom",
"IE": "Ireland",
"DE": "Germany",
"FR": "France",
}
let carriersList: any = {};
for (let country of countryArray) {
const matchedCarriers = carrierArray
.filter(c => c.includes(`*(${country})*`))
.map(c => c.replace(/\*.*/, '').trim());
const countryName = countryCodeToNameMapping[country];
carriersList[countryName] = matchedCarriers;
}
console.log(carriersList);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment