Skip to content

favourmark05/countries-directory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

countries-directory

A small TypeScript dataset of countries and phone dialing metadata.

Exports:

  • countries.ts — an array of interface.Country objects.
  • interface/country.ts — the TypeScript interface describing each record.

Quick links:

  • countries.ts
  • interface/country.ts

Purpose Provide a lightweight, fully typed list of countries with:

  • ISO country code (Code)
  • display name (name)
  • emoji flag (flag)
  • international dialing code (dialCode)
  • phone number maxLength for validation
  • phone number minLength for validation

API (shape) Each item follows the interface.Country interface:

  • name: string — human-readable country name
  • Code: string — two-letter ISO country code
  • flag: string — emoji flag
  • dialCode: string — international dialing prefix (e.g. +1)
  • maxLength: number — maximum national number length
  • minLength: number — minimum national number length

Usage

import type { Country } from './interface/country'
import { countries } from './countries'

const findByCode = (code: string): Country | undefined =>
  countries.find(c => c.Code.toUpperCase() === code.toUpperCase())

const nigeria = findByCode('NG')
console.log(nigeria?.dialCode) // => "+234"

Contributing See CONTRIBUTING.md for contribution guidelines.

License This dataset is provided under the MIT License. See LICENSE.

About

A small TypeScript dataset of countries and phone dialing metadata

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published