Exports an array of the iso-3166-1 countrycodes and iso-3166-2 subdivisions.
State of January of 2022
be in a nodejs project
npm install --save-exact @magic/iso-3166in yourproject.js
import{countries,subdivisions}from'@magic/iso-3166'// both countries and subdivisions are regular js arrays.constAfghanistanByName=countries.find(country=>country.name==='Afghanistan')/* returns{ name: 'Afghanistan', a2: 'AF', a3: 'AFG', num: '004' }*/constAmericanSamoaByAlphaNumeric2=countries.find(country=>country.a2==='AS')constAustraliaByAlphaNumeric3=countries.find(country=>country.a3==='AUS')constAntarcticaByNumeric=countries.find(country=>country.num==='010')constBrasilianSubdivisions=subdivisions.filter(sub=>sub.country==='BR')constAustrianSubdivisions=subdivisons.filter(sub=>sub.country==='AT')/* returns{ country: 'AT', code: '1', name: 'Burgenland', type: 'state' },{ country: 'AT', code: '2', name: 'Kärnten', type: 'state' },{ country: 'AT', code: '3', name: 'Niederösterreich', type: 'state' },{ country: 'AT', code: '4', name: 'Oberösterreich', type: 'state' },{ country: 'AT', code: '5', name: 'Salzburg', type: 'state' },{ country: 'AT', code: '6', name: 'Steiermark', type: 'state' },{ country: 'AT', code: '7', name: 'Tirol', type: 'state' },{ country: 'AT', code: '8', name: 'Vorarlberg', type: 'state' },{ country: 'AT', code: '9', name: 'Wien', type: 'state' }*/first publish
- add full list of countries to docs
- update dependencies
- update dependencies
- fix git repo url in docs
- update dependencies
- update dependencies
...