Code Monkey home page Code Monkey logo

currency-codes's Issues

Type definition of `numbers` is incorrect

This type definition is incorrect:

export function numbers(): number[];

The 'number' field in data is a string. There are two solutions to this:

  1. Update the definition to string[]
  2. Pass the value through the number constructor to make it a number

I'd be happy to open a PR for whichever solution is prefered. Personally, I'd prefer number to be an array of numbers :)

digits missing on typescript types.

Expected behaviour

import * as currencyCode from 'currency-codes';

currencyCode.code('EUR').digits
// 2

Actual behaviour

import * as currencyCode from 'currency-codes';

currencyCode.code('EUR').digits

// Property 'digits' does not exist on type 'CurrencyCodeRecord'

Solution

It should be added on ./index.d.ts as

declare module "currency-codes" {
  export interface CurrencyCodeRecord {
    code: string;
    number: number;
    currency: string;
    countries: string[];
    // HERE: digits: number;
  }

// ...

Disclosure

I can add it myself, but javascript/typescript is not my main language, so basically I don't know what I am doing. I would like confirmation from someone with more experience.

Thank you.

License

What license is this code under?

Cannot lookup AUD by number

If I do number(36), I get undefined, not AUD.

This is because the number lookup uses string comparisons, and there is a leading zero in the currency code.

I can work around this by doing: number(('000' + code).slice(-3)), which inserts the leading zeros as needed. This logic should probably move into the library itself.

Missing currency

MRO seems to be missing.

I'm not sure if that's an effort to keep the library current or not but people will have records going back while MRO was still in use so need that to maintain integrity.

For whatever reason it's missing, it would be useful to have an additional column to indicate if the currency is still in use / circulation or not.

Exclude data that are not real currencies

Hi, first of all thanks for your library, it's very useful!

I'm working with it and I see that in the array there are data that are not really coins, but are data for testing, and other objects that I don't even know if they are coins (I leave you some examples).
{
"code": "XXX",
"number": "999",
"digits": 0,
"currency": "The codes assigned for transactions where no currency is involved",
"countries": [
"Zz07_no_currency"
]
}
{
"code": "XTS",
"number": "963",
"digits": 0,
"currency": "Codes specifically reserved for testing purposes",
"countries": [
"Zz06_testing_code"
]
}
{
"code": "XPD",
"number": "964",
"digits": 0,
"currency": "Palladium",
"countries": [
"Zz09_palladium"
]
}
{
"code": "XPT",
"number": "962",
"digits": 0,
"currency": "Platinum",
"countries": [
"Zz10_platinum"
]
}
{
"code": "XUA",
"number": "965",
"digits": 0,
"currency": "ADB Unit of Account",
"countries": [
"Member Countries of the African Development Bank Group"
]
}
{
"code": "XDR",
"number": "960",
"digits": 0,
"currency": "SDR (Special Drawing Right)",
"countries": [
"International Monetary Fund (Imf)ย "
]
}

Is there any way to know which data are actually coins? I wanted to use the library in production but it doesn't work, because I don't know what data I have to exclude.

Thank you.

Better TypeScript support

Hi, first of all thanks for the great package.
I would like to point that I've had some issues with the package when using TypeScript, as the data array is not actually typed - codes() returns a string[] when it's supposed to be something like CurrencyCode[], because it is in fact a closed set of values (currency codes).

It led me to write this sort of a fork to this package: https://github.com/osskit/currencies

But I would really want to keep using this package instead - just if we could better granular types for the codes, return values of the getters, etc.
I'm not sure what's the maintaining status of this package, so I'll wait for a response, and in the mean time use the above suggested package.
Thanks in advance!

Running the test on travis ci

Hello,
i can create a travis ci config to add continuous integration to the project.
let me know if you ike the idea.

Nested dependency of axios can be a problem

Hi,

First of all, thanks for being develop this library, it is very useful :claps:

I just have feedback about the dependency of axios.

In my project, I can't depend on libraries that can do network connections, due to security restrictions.

Should you separate this dependency in another project for the fetch function, and keep a static one that doesn't have this dependency?

Missing currencies

It seems that currency code "933" - BYN - Belarusian ruble do not exist in your data even though it is part of ISO4217.
Do you accept pull requests for missing currencies or are you willing to add them yourself?

Best Regards
Thomas

Changelog

Hi!

Noticed a major version change, which normally means a breaking change according to semver, but I couldn't find any description on the release, nor a changelog or an addendum to the readme. Would it be possible to:

a) Describe the breaking change
b) Add it to a file or to the release description

Thanks.

Feature request - include ISO country codes

It would be useful to add a couple of parameters to the library, specifically the ISO 3166-1 country codes (Alpha 2, Alpha 3 and Numeric) to enable searching based on country.

Proposed to add extra objects like this:

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

I'd propose keeping the base structure and extending it to create an array of objects for each country. This could be a breaking change but would be extendable. The key could be the country name, but also keep this as a value for consistency of use.

This would allow for functionality to be built that allows for searching for currency based on country code.

Croatia currency change

The Kuna was the currency of Croatia until 31 December 2022., it was replaced by the Euro in 2023. For accuracy, updating HRK to EUR would be appreciated.

first-match.

I noticed you're using first-match, which stats that it's similar to _.find and thought you'd dig knowing there's a standalone module that's like a more powerful _.find.

You can do things like

// old way
first(data, function(c) {
  return c.code === code;
});

// new way
find(data, { code: code });

Using lodash

// old way
var m = data.filter(function(c) {
  return c.countries;
}).map(function(c) {
  return c.countries;
});

// new way
_(data).filter('countries').map('countries').value()

If you'd like a PR just let me know.

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.