country-and-province
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Province and Country

A library for ISO Country and Province data, wrapping two npm modules in an easy-to-use API.

This library currently uses country-list and provinces libraries as the data back-end. The main motivation for this library was to build out useful searching and resolving of country and province names and codes with an easy-to-understand API.

Usage

Install from NPM and import it.

const { Countries, Provinces, Country, Province } = require('./index.js')

console.log(Countries.byName('United States')) // Expected output: Country class with data for United States of America
console.log(new Country('CA')) // Expected output: Country class with data for Canada

console.log(Provinces.byCode('QC')) // Province class for Quebec, Canada
console.log(new Province('CA')) // Province class for California, United States
console.log(new Province('Newfoundland')) // Province class for Newfoundland, Canada

console.log(new Country('Spain').provinceByCode('CA')) // Province class for Cádiz, Spain

API

Self-documented within this repository.

Package Sidebar

Install

npm i country-and-province

Weekly Downloads

2,796

Version

2.0.0

License

MIT

Unpacked Size

11 kB

Total Files

5

Last publish

Collaborators

  • ahuggins_nhs