spb/countryatlas
Public
TypeScript 57%
Python 38.6%
JavaScript 3.6%
CSS 0.6%
1import type { IncomeGroup } from './types';23/** Static mirror of `registry/groups.yaml` regions (World Bank, 7) and income groups (4) used for filters/chips. */4export interface GroupDef {5 id: string;6 slug: string;7 name: string;8 short: string;9}1011export const WB_REGIONS: readonly GroupDef[] = [12 { id: 'NAC', slug: 'north-america', name: 'North America', short: 'N. America' },13 { id: 'LCN', slug: 'latin-america-caribbean', name: 'Latin America & Caribbean', short: 'Latin America' },14 { id: 'ECS', slug: 'europe-central-asia', name: 'Europe & Central Asia', short: 'Europe & C. Asia' },15 { id: 'MEA', slug: 'middle-east-north-africa', name: 'Middle East, North Africa, Afghanistan & Pakistan', short: 'MENA+' },16 { id: 'SAS', slug: 'south-asia', name: 'South Asia', short: 'South Asia' },17 { id: 'EAS', slug: 'east-asia-pacific', name: 'East Asia & Pacific', short: 'East Asia & Pacific' },18 { id: 'SSF', slug: 'sub-saharan-africa', name: 'Sub-Saharan Africa', short: 'Sub-Saharan Africa' },19];2021export const INCOME_GROUPS: readonly (GroupDef & { id: IncomeGroup })[] = [22 { id: 'HIC', slug: 'high-income', name: 'High income', short: 'High' },23 { id: 'UMC', slug: 'upper-middle-income', name: 'Upper middle income', short: 'Upper middle' },24 { id: 'LMC', slug: 'lower-middle-income', name: 'Lower middle income', short: 'Lower middle' },25 { id: 'LIC', slug: 'low-income', name: 'Low income', short: 'Low' },26];2728export function regionName(id: string | null | undefined): string | null {29 if (!id) return null;30 return WB_REGIONS.find((r) => r.id === id.toUpperCase())?.name ?? null;31}32export function regionShort(id: string | null | undefined): string | null {33 if (!id) return null;34 return WB_REGIONS.find((r) => r.id === id.toUpperCase())?.short ?? null;35}36export function regionSlug(id: string | null | undefined): string | null {37 if (!id) return null;38 return WB_REGIONS.find((r) => r.id === id.toUpperCase())?.slug ?? null;39}40