mirror of https://github.com/ghostfolio/ghostfolio
1 changed files with 17 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||||
|
import { countries } from 'countries-list'; |
||||
|
|
||||
|
export function getCountryCodeByName({ |
||||
|
aliases = {}, |
||||
|
name |
||||
|
}: { |
||||
|
aliases?: Record<string, string>; |
||||
|
name: string; |
||||
|
}): string { |
||||
|
for (const [code, country] of Object.entries(countries)) { |
||||
|
if (country.name === name || country.name === aliases[name]) { |
||||
|
return code; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return undefined; |
||||
|
} |
||||
Loading…
Reference in new issue