Giter Club home page Giter Club logo

country-list-js's Introduction

country-list-js's People

Contributors

cgehuzi avatar dependabot[bot] avatar ekkis avatar i-rocky avatar ifthenelse avatar martinkolarik avatar unilynx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

country-list-js's Issues

In Spain there are two provinces left

Working with the npm module, we find 2 provinces left in Spain. This provinces are Navarra and Asturias, both of this provinces have the same name as the region, maybe this is the reason why are not in the province JSON.

Neighbours

one thing that would be really useful is to be able to return neighbours of a country. I'm thinking about something like:

console.log(country.getNeighbours('US');)

to get:

['CA', 'MX', 'RU']

so maybe, down the line, when we have political subdivisions (I'll create a new issue for that), then we would extend the concept to it

I'm not sure I can spend a lot of time with it right now so if you're up for it, please feel free, but at least we have an issue for it and I can come back to it

and neighbours maybe could be segmented into contiguous neighbours and discontiguous, which would allow relationships with islands. so the US could be a neighbour of Jamaica. not sure that works all that well. perhaps, since we have regions now we could create neighbours for regions i.e. the Caribbean is a neighbour of North America

Babel broken

I've discovered a problem with the module, but not proper to the module itself

if the module is included into an environment that defines Object prototypes it breaks with the stack trace below.

the problem is that basically babel-traverse does shit like:

for (var k in o) { // do stuff }

when it should do:

for (var k in o) { if (o.hasOwnProperty(k)) { // do stuff }}

so I thought to patch their code but there are 633 open issues and 107 pull requests outstanding so I'd say the chance of fixing that is nil. could we remove babel? after all, the only use of it is in the import which can easily be replaced with the older require

-- stack trace ---

/Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/transformation/file/index.js:558
      throw err;
      ^

Error: /Users/ekkis/dev/country-list-js/src/index.js: You passed `traverse()` a visitor object with the property "ExportDeclaration" that has the invalid property "__test_function__"
    at verify (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/visitors.js:205:17)
    at Object.explode (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/visitors.js:72:3)
    at traverse (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/index.js:77:12)
    at NodePath.traverse (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/path/index.js:144:25)
    at Scope._crawl (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/scope/index.js:828:10)
    at Scope.crawl (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/scope/index.js:749:10)
    at Scope.init (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/scope/index.js:744:32)
    at NodePath.setScope (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/path/context.js:151:30)
    at NodePath.setContext (/Users/ekkis/dev/country-list-js/node_modules/babel-traverse/lib/path/context.js:166:8)
    at File._addAst (/Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/transformation/file/index.js:497:8)
    at File.addAst (/Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/transformation/file/index.js:505:10)
    at File.parseCode (/Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/transformation/file/index.js:571:10)
    at /Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/transformation/pipeline.js:49:12
    at File.wrap (/Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/transformation/file/index.js:532:16)
    at Pipeline.transform (/Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
    at Object.transformFileSync (/Users/ekkis/dev/country-list-js/node_modules/babel-core/lib/api/node.js:152:10)
    at compile (/Users/ekkis/dev/country-list-js/node_modules/babel-register/lib/node.js:118:20)
    at loader (/Users/ekkis/dev/country-list-js/node_modules/babel-register/lib/node.js:144:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/ekkis/dev/country-list-js/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/ekkis/dev/country-list-js/test/index.test.js:9:17)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at loader (/Users/ekkis/dev/country-list-js/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/ekkis/dev/country-list-js/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at /Users/ekkis/dev/country-list-js/node_modules/mocha/lib/mocha.js:231:27
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/Users/ekkis/dev/country-list-js/node_modules/mocha/lib/mocha.js:228:14)
    at Mocha.run (/Users/ekkis/dev/country-list-js/node_modules/mocha/lib/mocha.js:514:10)
    at Object.<anonymous> (/Users/ekkis/dev/country-list-js/node_modules/mocha/bin/_mocha:480:18)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)
    at startExecution (internal/bootstrap/node.js:276:5)
    at startup (internal/bootstrap/node.js:227:5)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! Test failed.  See above for more details.

French regions should not be in the country list.

Cache issue with code iso2 and iso3

When querying multiple times the same country, for example :

const countries = require('country-list-js')
const first = countries.findByIso3('USA')
const second = countries.findByIso3('USA')
console.log(first)
console.log('---')
console.log(second)

The output is correct the first time but not the following ones, for example (please see value for code in both results) :

{ name: 'United States',
  continent: 'North America',
  region: 'North America',
  capital: 'Washington',
  currency: { code: 'USD', symbol: '$', decimal: '2' },
  dialing_code: '1',
  provinces:
   [ { short: 'AL', name: 'Alabama', alias: null },
     { short: 'AK', name: 'Alaska', alias: null },
     { short: 'AZ', name: 'Arizona', alias: null },
     { short: 'AR', name: 'Arkansas', alias: null },
     { short: 'CA', name: 'California', alias: null },
     { short: 'CO', name: 'Colorado', alias: null },
     { short: 'CT', name: 'Connecticut', alias: null },
     { short: 'DC', name: 'District of Columbia', alias: null },
     { short: 'DE', name: 'Delaware', alias: null },
     { short: 'FL', name: 'Florida', alias: null },
     { short: 'FM', name: 'Micronesia', alias: null },
     { short: 'GA', name: 'Georgia', alias: null },
     { short: 'HI', name: 'Hawaii', alias: null },
     { short: 'ID', name: 'Idaho', alias: null },
     { short: 'IL', name: 'Illinois', alias: null },
     { short: 'IN', name: 'Indiana', alias: null },
     { short: 'IA', name: 'Iowa', alias: null },
     { short: 'KS', name: 'Kansas', alias: null },
     { short: 'KY', name: 'Kentucky', alias: null },
     { short: 'LA', name: 'Louisiana', alias: null },
     { short: 'ME', name: 'Maine', alias: null },
     { short: 'MD', name: 'Maryland', alias: null },
     { short: 'MA', name: 'Massachusetts', alias: null },
     { short: 'MI', name: 'Michigan', alias: null },
     { short: 'MN', name: 'Minnesota', alias: null },
     { short: 'MH', name: 'Marshall Islands', alias: null },
     { short: 'MS', name: 'Mississippi', alias: null },
     { short: 'MO', name: 'Missouri', alias: null },
     { short: 'MT', name: 'Montana', alias: null },
     { short: 'NE', name: 'Nebraska', alias: null },
     { short: 'NV', name: 'Nevada', alias: null },
     { short: 'NH', name: 'New Hampshire', alias: null },
     { short: 'NJ', name: 'New Jersey', alias: null },
     { short: 'NM', name: 'New Mexico', alias: null },
     { short: 'NY', name: 'New York', alias: null },
     { short: 'NC', name: 'North Carolina', alias: null },
     { short: 'ND', name: 'North Dakota', alias: null },
     { short: 'OH', name: 'Ohio', alias: null },
     { short: 'OK', name: 'Oklahoma', alias: null },
     { short: 'OR', name: 'Oregon', alias: null },
     { short: 'PA', name: 'Pennsylvania', alias: null },
     { short: 'PW', name: 'Palau', alias: null },
     { short: 'RI', name: 'Rhode Island', alias: null },
     { short: 'SC', name: 'South Carolina', alias: null },
     { short: 'SD', name: 'South Dakota', alias: null },
     { short: 'TN', name: 'Tennessee', alias: null },
     { short: 'TX', name: 'Texas', alias: null },
     { short: 'UT', name: 'Utah', alias: null },
     { short: 'VT', name: 'Vermont', alias: null },
     { short: 'VA', name: 'Virginia', alias: null },
     { short: 'WA', name: 'Washington', alias: null },
     { short: 'WV', name: 'West Virginia', alias: null },
     { short: 'WI', name: 'Wisconsin', alias: null },
     { short: 'WY', name: 'Wyoming', alias: null },
     { short: 'AS', name: 'American Samoa', alias: null },
     { short: 'GU', name: 'Guam', alias: null },
     { short: 'MP', name: 'Northern Mariana Islands', alias: null },
     { short: 'PR', name: 'Puerto Rico', alias: null },
     { short: 'UM',
       name: 'United States Minor Outlying Islands',
       alias: null },
     { short: 'VI', name: 'Virgin Islands', alias: null } ],
  code: { iso2: 'US', iso3: 'USA' } }
---
{ name: 'United States',
  continent: 'North America',
  region: 'North America',
  capital: 'Washington',
  currency:
   { code: { code: 'USD', symbol: '$', decimal: '2' },
     symbol: undefined,
     decimal: undefined },
  dialing_code: '1',
  provinces:
   [ { short: 'AL', name: 'Alabama', alias: null },
     { short: 'AK', name: 'Alaska', alias: null },
     { short: 'AZ', name: 'Arizona', alias: null },
     { short: 'AR', name: 'Arkansas', alias: null },
     { short: 'CA', name: 'California', alias: null },
     { short: 'CO', name: 'Colorado', alias: null },
     { short: 'CT', name: 'Connecticut', alias: null },
     { short: 'DC', name: 'District of Columbia', alias: null },
     { short: 'DE', name: 'Delaware', alias: null },
     { short: 'FL', name: 'Florida', alias: null },
     { short: 'FM', name: 'Micronesia', alias: null },
     { short: 'GA', name: 'Georgia', alias: null },
     { short: 'HI', name: 'Hawaii', alias: null },
     { short: 'ID', name: 'Idaho', alias: null },
     { short: 'IL', name: 'Illinois', alias: null },
     { short: 'IN', name: 'Indiana', alias: null },
     { short: 'IA', name: 'Iowa', alias: null },
     { short: 'KS', name: 'Kansas', alias: null },
     { short: 'KY', name: 'Kentucky', alias: null },
     { short: 'LA', name: 'Louisiana', alias: null },
     { short: 'ME', name: 'Maine', alias: null },
     { short: 'MD', name: 'Maryland', alias: null },
     { short: 'MA', name: 'Massachusetts', alias: null },
     { short: 'MI', name: 'Michigan', alias: null },
     { short: 'MN', name: 'Minnesota', alias: null },
     { short: 'MH', name: 'Marshall Islands', alias: null },
     { short: 'MS', name: 'Mississippi', alias: null },
     { short: 'MO', name: 'Missouri', alias: null },
     { short: 'MT', name: 'Montana', alias: null },
     { short: 'NE', name: 'Nebraska', alias: null },
     { short: 'NV', name: 'Nevada', alias: null },
     { short: 'NH', name: 'New Hampshire', alias: null },
     { short: 'NJ', name: 'New Jersey', alias: null },
     { short: 'NM', name: 'New Mexico', alias: null },
     { short: 'NY', name: 'New York', alias: null },
     { short: 'NC', name: 'North Carolina', alias: null },
     { short: 'ND', name: 'North Dakota', alias: null },
     { short: 'OH', name: 'Ohio', alias: null },
     { short: 'OK', name: 'Oklahoma', alias: null },
     { short: 'OR', name: 'Oregon', alias: null },
     { short: 'PA', name: 'Pennsylvania', alias: null },
     { short: 'PW', name: 'Palau', alias: null },
     { short: 'RI', name: 'Rhode Island', alias: null },
     { short: 'SC', name: 'South Carolina', alias: null },
     { short: 'SD', name: 'South Dakota', alias: null },
     { short: 'TN', name: 'Tennessee', alias: null },
     { short: 'TX', name: 'Texas', alias: null },
     { short: 'UT', name: 'Utah', alias: null },
     { short: 'VT', name: 'Vermont', alias: null },
     { short: 'VA', name: 'Virginia', alias: null },
     { short: 'WA', name: 'Washington', alias: null },
     { short: 'WV', name: 'West Virginia', alias: null },
     { short: 'WI', name: 'Wisconsin', alias: null },
     { short: 'WY', name: 'Wyoming', alias: null },
     { short: 'AS', name: 'American Samoa', alias: null },
     { short: 'GU', name: 'Guam', alias: null },
     { short: 'MP', name: 'Northern Mariana Islands', alias: null },
     { short: 'PR', name: 'Puerto Rico', alias: null },
     { short: 'UM',
       name: 'United States Minor Outlying Islands',
       alias: null },
     { short: 'VI', name: 'Virgin Islands', alias: null } ],
  code: { iso2: undefined, iso3: undefined } }

Italy don't have provinces

Hi to everyone

I've installed this package but unfortunately Italy don't have provinces so I can't use it because is incomplete.
There is a way to contribute with the province list to update this state?

Italian provinces gives null

Hi

I'm the girl who some time ago made a PR about adding Italian provinces.
Finally today I was able to return on the project where I need the provinces that I've added.
I've updated the library and tried to retrieve all the states using 'countries.all,' and I noticed that in the Italian state, the 'provinces' key is still null. Is there any issue with the feature? I'm using version 3.1.7, which I also see is the latest in the package.

Thanks

Wiki

here's a thought: we're currently managing the information in .json files. it's a suitable solution for a node module, but we have to maintain the data... could we build a module to store the data in wikidata?

then create a Javascript module to extract the data from wikimedia and create the .json files in the module. that would allow us to export the maintenance of these data. someone else takes care of it.

something we should think about

Missing phone country codes? eg AC/+247 (ascension island)

I was seeing whether I could swap out libphonenumber-js (https://gitlab.com/catamphetamine/libphonenumber-js) for the phone.json datafile (as I only need the dialing codes and not the full formats).

But there appears to be a difference in the actual data. Eg, libphonenumber-js lists Ascension Island (AC, country code 247) here: https://gitlab.com/catamphetamine/libphonenumber-js/-/blob/master/PhoneNumberMetadata.xml?ref_type=heads#L104 but AC is not in data/phone.json

Is this intentional (is country-list-js limited in scope) or is this just some missing data?

The package doesn't support TypeScript

the package doesn't support Typescript
I tried to run the package on react project and then I received and typescript error,
it shows the code property and it doesn't exist in the object, and when I tried to go to the property directly it showed in error

image
image
image

Political subdivisions

I've always wanted to have a source for political subdivisions. it's a complex matter but we should attempt it. part of the proposition would address terminology i.e. is is a province, a department, at prefecture?

and maybe go down a level or 2. Australia, for example, has territories, underneath states (and those are broken up too). Russia has oblasts

we should give it a try

Which ISO standards for country name?

I'm not sure which ISO standards does this package follows for the country name. The common one that I found is ISO 3166-1. If we adhere to ISO 3166-1, country name United States should be United States of America instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.