Code Monkey home page Code Monkey logo

Comments (9)

maxsommer avatar maxsommer commented on July 28, 2024 3

@freeall Sure, I'm currently on it. However I've found a few points where I'd love your input.

  • What is currently the way to update the data (in data.js)? Was the data somehow imported from the ISO website (e.g. via their exposed XML file)?
  • What would you think of automating the update process fully by pulling the data from the Wikipedia pages (if not already done and I overlooked it or was not included in code) or via the ISO homepage?
  • Would the Wikpedia pages e.g. for you be a respectable data source? See Wikipedia ISO 4217 and Wikpedia ISO 3166 for reference. The reason I'm proposing this is that ISO is actually charing money for consumption of at least their country code list in structured format see ISO 3166.
  • What would you consider a useful data model for the isoCountries property? I based my proposition on the data table found in Wikipedia ISO 3166:
interface Country {
  name?: string;
  shortname?: string;
  sovereignity?: string;
  iso2?: string;
  iso3?: string;
  numeric?: string;
  subdivisionCode?: string;
}

How should I go from here? I cloned the repository and built a script to update basically all the data (see here) – I think the changes I made there would be breaking however as they would introduce changes to the current dataset (e.g. "Afghani" became "Afghan afghani" because of the data source change). There are multiple ways of going forward for me:

  • Keep the current main data set, only pull ISO Country data from Wikipedia and enhance the current dataset via script (aka stay non-breaking)
  • Be ok introducing a new major version with modified data set and import data in automated fashion from Wikipedia
  • Don't use Wikipedia as datasource at all, switch to official ISO data and e.g. crawl their country codes list and rebuild on top of that

One cool side effect from switching to Wikipedia as data source we could have as a benefit is actually internationalization of the content – the content could be pulled in as many languages as are provided in Wikipedia and be an optional argument when interacting with the library e.g.

const cc = require('currency-codes');
console.log(cc.code('EUR'));
console.log(cc.code('EUR', 'de'));

Of course this doesn't have to be the librarys scope it's for you to decide :) In combination with a Typescript based rewrite and an automatically executed test suite this could be a full new major version as well.

Depending on what your oppinions are I will make according changes and file a pull request. Please have a look at my proposal here

from currency-codes.

freeall avatar freeall commented on July 28, 2024 1

I think this might be out of scope for this module. I am not entirely sure though.

from currency-codes.

maxsommer avatar maxsommer commented on July 28, 2024 1

@Spomky I kept numberic field a type string because it seems like according to standard there are numeric identifiers with leading 0 such as 020 for Andorra. Seemed unintuitive for me as well and we could also argue this could be handled internally but I'd rather adhere to seemingly standard 😄

from currency-codes.

eXeDK avatar eXeDK commented on July 28, 2024

I agree that this valuable information however as you point out this is a breaking change.
If you come up with a solution that is not breaking the existing API in a meaningful way I think we should look into it!

from currency-codes.

maxsommer avatar maxsommer commented on July 28, 2024

I would definitely agree this should be done in this library. To make it a non-breaking change this could also be acceptable:

{
  code: 'ZMW',
  number: 967,
  digits: 2,
  currency: 'Zambian kwacha',
  countries: [ 'zambia' ],
  isoCountries: [ 
    {
      'name': 'zambia',
      'iso2': 'ZM',
      'iso3': 'ZMB',
      'numeric': '894'
    } 
  ]
}

from currency-codes.

freeall avatar freeall commented on July 28, 2024

@maxsommer that's not a bad idea at all. If you make a PR that would include this, I'll add it. Preferably in a way that could be done automatically whenever there's updates to the data set.

from currency-codes.

maxsommer avatar maxsommer commented on July 28, 2024

Hey @freeall any feedback would be appreciated.

from currency-codes.

Spomky avatar Spomky commented on July 28, 2024

This is a nice feature I would love to have.
Just one question though: why numeric is of type string? Is there any reason to return a string instead a positive integer?

from currency-codes.

Spomky avatar Spomky commented on July 28, 2024

there are numeric identifiers with leading 0 such as 020 for Andorra

OK I was not aware of that. Makes sense to let it as a string. Thanks for the explanation.

from currency-codes.

Related Issues (20)

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.