{"_id":"currency-codes-ts","name":"currency-codes-ts","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"currency-codes-ts","version":"3.0.0","description":"A TypeScript library for ISO 4217 currency codes. Efficiently lookup and validate currency codes, retrieve associated countries, and more.","type":"module","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git://github.com/reportingdev/currency-codes-ts.git"},"homepage":"https://github.com/reportingdev/currency-codes-ts#readme","bugs":{"url":"https://github.com/reportingdev/currency-codes-ts/issues"},"author":{"name":"Braden Ericson","email":"developers@reporting.dev"},"dependencies":{"lodash-es":"^4.17.21"},"devDependencies":{"@gouch/to-title-case":"^2.2.1","@types/lodash-es":"^4.17.9","assert":"^2.1.0","axios":"^0.19.2","xml2js":"^0.4.23"},"scripts":{"test":"node test.mjs","iso:fetch-xml":"node scripts/fetch-iso-4217-xml.cjs","iso:ingest-xml":"node scripts/ingest-iso-4217-xml.cjs","iso":"npm run iso:fetch-xml && npm run iso:ingest-xml"},"engines":{"node":">=14"},"private":false,"license":"MIT","keywords":["iso4217","iso","4217","currency","currencies","code","codes","lookup","finance","exchange","conversion","money","country","international","banking","rate","data","financial","fintech","payment","symbol","json","api","utils","utility","global","localization","i18n","typescript"],"gitHead":"ae347f5cc9147f53eb7983ae5ee0722146d399c7","_id":"currency-codes-ts@3.0.0","_nodeVersion":"19.2.0","_npmVersion":"8.19.3","dist":{"integrity":"sha512-ZJeCpq5uY2t8dDl4xdF15shkp5o8jrHcD4lHftK/O8j8xTHlXg0E5YhpZbRJvnLRaKe+JQh1/q1AI9Wc2Dl3Nw==","shasum":"1bffce1b0949fa669972a566c2b27a4705eb8c66","tarball":"https://registry.npmjs.org/currency-codes-ts/-/currency-codes-ts-3.0.0.tgz","fileCount":11,"unpackedSize":53830,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICZGUKBVrKCClHvIFE0SkwmJHOVyXUbb1BtM3jo9EcZPAiBcWXG1TulaiPPfD+y70rv3gnxfcdIDQr4Y3owWTdS05g=="}]},"_npmUser":{"name":"braden","email":"bce94@yahoo.com"},"directories":{},"maintainers":[{"name":"braden","email":"bce94@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/currency-codes-ts_3.0.0_1696393786368_0.2882607347802417"},"_hasShrinkwrap":false}},"time":{"created":"2023-10-04T04:29:46.367Z","3.0.0":"2023-10-04T04:29:46.592Z","modified":"2023-10-04T04:29:46.877Z"},"maintainers":[{"name":"braden","email":"bce94@yahoo.com"}],"description":"A TypeScript library for ISO 4217 currency codes. Efficiently lookup and validate currency codes, retrieve associated countries, and more.","homepage":"https://github.com/reportingdev/currency-codes-ts#readme","keywords":["iso4217","iso","4217","currency","currencies","code","codes","lookup","finance","exchange","conversion","money","country","international","banking","rate","data","financial","fintech","payment","symbol","json","api","utils","utility","global","localization","i18n","typescript"],"repository":{"type":"git","url":"git://github.com/reportingdev/currency-codes-ts.git"},"author":{"name":"Braden Ericson","email":"developers@reporting.dev"},"bugs":{"url":"https://github.com/reportingdev/currency-codes-ts/issues"},"license":"MIT","readme":"# Currency Codes TS\n\nA TypeScript library for ISO 4217 currency codes. Efficiently lookup and validate currency codes, retrieve associated countries, and more.\n\nThis library is inspired by and originally forked from [currency-codes](https://github.com/smirzaei/currency-codes). This version adds TypeScript support and will be periodically updated with the latest currency data.\n\n## Installation\n\n```bash\nnpm install currency-codes-ts\n```\n\n## Examples\n\nHere's how you can use the library:\n\n#### Code lookup\n\n```typescript\nimport { codes } from 'currency-codes-ts';\n\n// get currency details\nconst euroInfo: CurrencyCodeRecord = currencyCodes.code('EUR');\nconsole.log(euroInfo);  \n\n/*\n  {\n    code: 'EUR',\n    number: '978',\n    digits: 2,\n    currency: 'Euro',\n    countries: [\n      'Åland Islands', 'Andorra', 'Austria', 'Belgium', 'Croatia',\n      'Cyprus', 'Estonia', 'European Union', 'Finland', 'France',\n      'French Guiana', 'French Southern Territories (The)', 'Germany',\n      'Greece', 'Guadeloupe', 'Holy See (The)', 'Ireland', 'Italy',\n      'Latvia', 'Lithuania', 'Luxembourg', 'Malta', 'Martinique',\n      'Mayotte', 'Monaco', 'Montenegro', 'Netherlands (The)',\n      'Portugal', 'Réunion', 'Saint Barthélemy', 'Saint Martin (French Part)',\n      'Saint Pierre and Miquelon', 'San Marino', 'Slovakia', 'Slovenia',\n      'Spain'\n    ]\n  }\n*/\n```\n\n#### Number Lookup\n\n```typescript\nimport { number } from 'currency-codes-ts';\n\nconsole.log(number(967))\n\n/*\n  {\n    code: 'ZMW',\n    number: '967',\n    digits: 2,\n    currency: 'Zambian Kwacha',\n    countries: [ 'Zambia' ]\n  }\n*/\n```\n\n#### Country Lookup\n\n```typescript\nimport { country } from 'currency-codes-ts';\n\nconsole.log(country('Columbia'))\n\n/*\n  [\n    {\n      code: 'COP',\n      number: '170',\n      digits: 2,\n      currency: 'Colombian Peso',\n      countries: [ 'Colombia' ]\n    },\n    {\n      code: 'COU',\n      number: '970',\n      digits: 2,\n      currency: 'Unidad de Valor Real',\n      countries: [ 'Colombia' ]\n    }\n  ]\n*/\n```\n\n#### Get all Currency Codes\n\n```typescript\nimport { codes } from 'currency-codes-ts';\n\nconsole.log(codes())\n\n/*\n  [\n    'AED',\n    'AFN',\n    ...\n    'ZAR',\n    'ZMW'\n  ]\n*/\n```\n\n#### Get all Currency Numbers\n\n```typescript\nimport { numbers } from 'currency-codes-ts';\n\nconsole.log(numbers())\n\n/*\n[\n\t'784',\n\t'971',\n\t...\n\t'710',\n\t'967'\n]\n*/\n```\n\n#### Get all Countries\n\n```typescript\nimport { countries } from 'currency-codes-ts';\n\nconsole.log(countries())\n\n/*\n[ \n\t'united arab emirates',\n\t'afghanistan',\n\t...\n]\n*/\n```\n\n#### Get all currency records\n\n```typescript\nimport { data } from 'currency-codes-ts';\n\nconsole.log(data)\n\n/*\n[{\n\tcode: 'AED',\n\tnumber: '784',\n\tdigits: 2,\n\tcurrency: 'United Arab Emirates dirham',\n\tcountries: ['united arab emirates']\n}, {\n\tcode: 'AFN',\n\tnumber: '971',\n\tdigits: 2,\n\tcurrency: 'Afghan afghani',\n\tcountries: ['afghanistan']\n}, {\n\t...\n}]\n*/\n```\n\n## Functions\n\n- `code(code: string)`: Returns a `CurrencyCodeRecord` object based on ISO 4217 currency code. Returns `undefined` if not found.\n- `country(country: string)`: Returns an array of `CurrencyCodeRecord` objects used in the given country.\n- `number(number: number | string)`: Returns a `CurrencyCodeRecord` object based on ISO 4217 currency number. Returns `undefined` if not found.\n- `codes()`: Returns an array of ISO 4217 currency codes.\n- `numbers()`: Returns an array of ISO 4217 currency numbers.\n- `countries()`: Returns an array of country names.\n\n## Properties\n- `data`: Returns a `CurrencyCodeRecord[]` array containing all the available currency records.\n- `publishDate`: Returns the ISO formatted date the currencies were last updated.\n\n## Types\n\n- `CurrencyCodeRecord`: Defines the object returned on currency lookup. Includes properties like `currency`, `code`, `countries`, and `digits`.\n\n```typescript\ninterface CurrencyCodeRecord {\n  code: CurrencyCode;\n  number: string;\n  digits: number;\n  currency: string;\n  countries: Country[];\n}\n```\n\n- `CurrencyCode`: The three-letter ISO 4217 code representing a currency (e.g., USD, EUR).\n\n```typescript\ntype CurrencyCode = \"AED\" | \"AFN\" | \"ALL\" | \"AMD\" | \"[...]\" | \"ZMW\" | \"ZWL\";\n```\n\n- `Country`: A string representing the name of a country.\n\n```typescript\ntype Country = \"United Arab Emirates (The)\" | \"Afghanistan\" | \"Albania\" | \"Armenia\" | \"[...]\" | \"Zambia\" | \"Zimbabwe\";\n```\n\n## Contributing\n\nYou can update the package with the latest currency data by running \n```bash \nnpm run iso\n```\nThis will update the `data.ts` and `types.ts` file based on the ingested data.\n\nTo build simply run `tsc`. This will create a build in the `dist/` folder.\n\nFor contributions feel free to raise issues and pull requests.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}