freeall / currency-codes Goto Github PK
View Code? Open in Web Editor NEWNode.js module to work with currency codes based on ISO 4217
License: MIT License
Node.js module to work with currency codes based on ISO 4217
License: MIT License
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.
the scripts are pointing to a 404 not found page : https://www.currency-iso.org/dam/downloads/lists/list_one.xml
should retrieve value from : https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml
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?
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.
For instance, the USA shows USN and USD and some others, but the actual daily use currency is USD and that's typically what I want to be retrieving. many other countries have such secondary currencies.
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.
SIX group, the ISO 4217 maintainer, says that the numeric code 532
will be associated with the new alpha code XCG
. The existing ANG
will be replaced. The effective date is 31 March 2025. I'll create an issue for now.
currency-codes/iso-4217-list-one.xml
Line 1351 in 6de7fe6
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.
Thanks!
Hello,
i can create a travis ci config to add continuous integration to the project.
let me know if you ike the idea.
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.
What license is this code under?
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.
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!
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
Maybe this has changed in a recent version of NPM, I don't know. But loading the module triggers an error:
Error: Cannot find module './data'
Some background: I'm using Meteor by the way, maybe that's relevant.
This type definition is incorrect:
Line 18 in 6de7fe6
The 'number' field in data is a string. There are two solutions to this:
string[]
I'd be happy to open a PR for whichever solution is prefered. Personally, I'd prefer number
to be an array of numbers :)
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.
import * as currencyCode from 'currency-codes';
currencyCode.code('EUR').digits
// 2
import * as currencyCode from 'currency-codes';
currencyCode.code('EUR').digits
// Property 'digits' does not exist on type 'CurrencyCodeRecord'
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;
}
// ...
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.
Its nice if you add currency symbols also to the data.js
cc.country('United Kingdom') is not returning anything, because the name on ISO file is like this: "United Kingdom of Great Britain and Northern Ireland (The)"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.