Gathering detailed insights and metrics for @reportingdev/currency-codes
Gathering detailed insights and metrics for @reportingdev/currency-codes
Gathering detailed insights and metrics for @reportingdev/currency-codes
Gathering detailed insights and metrics for @reportingdev/currency-codes
Node.js module to work with currency codes based on ISO 4217
npm install @reportingdev/currency-codes
Typescript
Module System
Min. Node Version
Node Version
NPM Version
74.2
Supply Chain
99.4
Quality
75.5
Maintenance
100
Vulnerability
99.6
License
TypeScript (87.51%)
JavaScript (12.49%)
Total Downloads
548
Last Day
2
Last Week
2
Last Month
10
Last Year
184
MIT License
1 Stars
39 Commits
2 Forks
2 Branches
1 Contributors
Updated on Oct 04, 2023
Minified
Minified + Gzipped
Latest Version
3.0.2
Package Id
@reportingdev/currency-codes@3.0.2
Unpacked Size
52.58 kB
Size
11.45 kB
File Count
11
NPM Version
8.19.3
Node Version
19.2.0
Published on
Oct 04, 2023
Cumulative downloads
Total Downloads
Last Day
0%
2
Compared to previous day
Last Week
100%
2
Compared to previous week
Last Month
-44.4%
10
Compared to previous month
Last Year
-49.5%
184
Compared to previous year
1
5
A TypeScript library for ISO 4217 currency codes. Efficiently lookup and validate currency codes, retrieve associated countries, and more.
This library is inspired by and originally forked from currency-codes. This version adds TypeScript support and will be periodically updated with the latest currency data.
1npm install currency-codes-ts
Here's how you can use the library:
1import { codes } from 'currency-codes-ts'; 2 3// get currency details 4const euroInfo: CurrencyCodeRecord = currencyCodes.code('EUR'); 5console.log(euroInfo); 6 7/* 8 { 9 code: 'EUR', 10 number: '978', 11 digits: 2, 12 currency: 'Euro', 13 countries: [ 14 'Åland Islands', 'Andorra', 'Austria', 'Belgium', 'Croatia', 15 'Cyprus', 'Estonia', 'European Union', 'Finland', 'France', 16 'French Guiana', 'French Southern Territories (The)', 'Germany', 17 'Greece', 'Guadeloupe', 'Holy See (The)', 'Ireland', 'Italy', 18 'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Martinique', 19 'Mayotte', 'Monaco', 'Montenegro', 'Netherlands (The)', 20 'Portugal', 'Réunion', 'Saint Barthélemy', 'Saint Martin (French Part)', 21 'Saint Pierre and Miquelon', 'San Marino', 'Slovakia', 'Slovenia', 22 'Spain' 23 ] 24 } 25*/
1import { number } from 'currency-codes-ts'; 2 3console.log(number(967)) 4 5/* 6 { 7 code: 'ZMW', 8 number: '967', 9 digits: 2, 10 currency: 'Zambian Kwacha', 11 countries: [ 'Zambia' ] 12 } 13*/
1import { country } from 'currency-codes-ts'; 2 3console.log(country('Columbia')) 4 5/* 6 [ 7 { 8 code: 'COP', 9 number: '170', 10 digits: 2, 11 currency: 'Colombian Peso', 12 countries: [ 'Colombia' ] 13 }, 14 { 15 code: 'COU', 16 number: '970', 17 digits: 2, 18 currency: 'Unidad de Valor Real', 19 countries: [ 'Colombia' ] 20 } 21 ] 22*/
1import { codes } from 'currency-codes-ts'; 2 3console.log(codes()) 4 5/* 6 [ 7 'AED', 8 'AFN', 9 ... 10 'ZAR', 11 'ZMW' 12 ] 13*/
1import { numbers } from 'currency-codes-ts'; 2 3console.log(numbers()) 4 5/* 6[ 7 '784', 8 '971', 9 ... 10 '710', 11 '967' 12] 13*/
1import { countries } from 'currency-codes-ts'; 2 3console.log(countries()) 4 5/* 6[ 7 'united arab emirates', 8 'afghanistan', 9 ... 10] 11*/
1import { data } from 'currency-codes-ts'; 2 3console.log(data) 4 5/* 6[{ 7 code: 'AED', 8 number: '784', 9 digits: 2, 10 currency: 'United Arab Emirates dirham', 11 countries: ['united arab emirates'] 12}, { 13 code: 'AFN', 14 number: '971', 15 digits: 2, 16 currency: 'Afghan afghani', 17 countries: ['afghanistan'] 18}, { 19 ... 20}] 21*/
code(code: string)
: Returns a CurrencyCodeRecord
object based on ISO 4217 currency code. Returns undefined
if not found.country(country: string)
: Returns an array of CurrencyCodeRecord
objects used in the given country.number(number: number | string)
: Returns a CurrencyCodeRecord
object based on ISO 4217 currency number. Returns undefined
if not found.codes()
: Returns an array of ISO 4217 currency codes.numbers()
: Returns an array of ISO 4217 currency numbers.countries()
: Returns an array of country names.data
: Returns a CurrencyCodeRecord[]
array containing all the available currency records.publishDate
: Returns the ISO formatted date the currencies were last updated.CurrencyCodeRecord
: Defines the object returned on currency lookup. Includes properties like currency
, code
, countries
, and digits
.1interface CurrencyCodeRecord { 2 code: CurrencyCode; 3 number: string; 4 digits: number; 5 currency: string; 6 countries: Country[]; 7}
CurrencyCode
: The three-letter ISO 4217 code representing a currency (e.g., USD, EUR).1type CurrencyCode = "AED" | "AFN" | "ALL" | "AMD" | "[...]" | "ZMW" | "ZWL";
Country
: A string representing the name of a country.1type Country = "United Arab Emirates (The)" | "Afghanistan" | "Albania" | "Armenia" | "[...]" | "Zambia" | "Zimbabwe";
You can update the package with the latest currency data by running
1npm run iso
This will update the data.ts
and types.ts
file based on the ingested data.
To build simply run tsc
. This will create a build in the dist/
folder.
For contributions feel free to raise issues and pull requests.
MIT
No vulnerabilities found.
No security vulnerabilities found.