Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aaronhuggins/country-and-province
A library for ISO Country and Province data, wrapping two NPM modules in an easy-to-use API.
https://github.com/aaronhuggins/country-and-province
country iso-country province province-data
Last synced: 9 days ago
JSON representation
A library for ISO Country and Province data, wrapping two NPM modules in an easy-to-use API.
- Host: GitHub
- URL: https://github.com/aaronhuggins/country-and-province
- Owner: aaronhuggins
- Created: 2020-04-01T16:42:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T18:38:31.000Z (almost 2 years ago)
- Last Synced: 2024-10-03T08:47:40.659Z (about 1 month ago)
- Topics: country, iso-country, province, province-data
- Language: TypeScript
- Homepage:
- Size: 674 KB
- Stars: 1
- Watchers: 0
- Forks: 1
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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.
```javascript
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 Canadaconsole.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, Canadaconsole.log(new Country('Spain').provinceByCode('CA')) // Province class for Cádiz, Spain
```
## API
Self-documented within [this repository](./docs/modules.md).