worldwide
A typed, offline database of world countries.
Update the list of countries with with gleam run -m worldwide/pull_countries.
Quick start
import worldwide
import worldwide/country.{type Country}
pub fn main() {
worldwide.all()
// -> [Country(..), ..]
}
See the worldwide/country module for more details.
Types
Filters that can be used to quickly get subsets of the worldwide data.
pub type Filter {
NameContains(String)
Region(region.Region)
Subregion(region.Subregion)
Currency(String)
Language(String)
CallingCode(String)
TimeZone(duration.Duration)
}
Constructors
-
NameContains(String)Filters by names containing the provided
String. -
Region(region.Region)Filters by the provided
Region. -
Subregion(region.Subregion)Filters by the provided
Subregion. -
Currency(String)Filters by the provided
Currency. -
Language(String)Filters by the provided
Language. -
CallingCode(String)Filters by the provided
CallingCode. -
TimeZone(duration.Duration)Filters by the provided
TimeZone.
Values
pub fn currencies() -> List(currency.Currency)
Returns every currency as a typed value.
pub fn filter_by(
countries: List(country.Country),
filter: Filter,
) -> List(country.Country)
Used to filter countries by the supported filters.
import worldwide
import worldwide.region.{Europe}
pub fn main() {
worldwide.all()
|> worldwide.filter_by(worldwide.Region(Europe))
// -> [Country(region: Europe, ..), ..]
}
pub fn languages() -> List(language.Language)
Returns every language as a typed value.
pub fn timezones() -> List(duration.Duration)
Returns every timezone as a typed value.