{"_id":"locale-currency","_rev":"7-0ce27da9e625d228de67bfedd7a11352","name":"locale-currency","dist-tags":{"latest":"1.0.0"},"versions":{"0.0.1":{"name":"locale-currency","version":"0.0.1","author":{"name":"Thomas Deegan","email":"tadeegan@gmail.com"},"license":"BSD-2-Clause","_id":"locale-currency@0.0.1","maintainers":[{"name":"tadeegan","email":"tadeegan@gmail.com"}],"homepage":"https://github.com/tadeegan/locale-currency#readme","bugs":{"url":"https://github.com/tadeegan/locale-currency/issues"},"dist":{"shasum":"c9e15a22ff575b4b4bb947a4bf92ac236bd1fe9b","tarball":"https://registry.npmjs.org/locale-currency/-/locale-currency-0.0.1.tgz","integrity":"sha512-r4gOinchOcF0U4NXkG4F70fB/3vqTdmRi7dLAZQL6pAMTZwbL6sXMG/QePW3lIBmQ3XavblrZkoSmJg4s8h+yQ==","signatures":[{"sig":"MEQCIAlo5s8fOuEuCawxArVm6C0cSSR2hb+cB1rmfGs+4fVRAiA5LO8JlnSfUfI5gIGwW5olXJv1slQpCO5/cF/y9KXWkw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"c9e15a22ff575b4b4bb947a4bf92ac236bd1fe9b","gitHead":"830ea1bf233daf20cf55e250095a68d8b8c53820","scripts":{"test":"node test.js"},"_npmUser":{"name":"tadeegan","email":"tadeegan@gmail.com"},"repository":{"url":"git+https://github.com/tadeegan/locale-currency.git","type":"git"},"_npmVersion":"3.8.5","description":"A map of i18n country codes to ISO 4217 currency codes.  Originally generated from the output of java.util.Currency.getInstance(locale)","_nodeVersion":"0.10.18","dependencies":{},"_npmOperationalInternal":{"tmp":"tmp/locale-currency-0.0.1.tgz_1459721025565_0.8142437166534364","host":"packages-12-west.internal.npmjs.com"},"directories":{}},"0.0.2":{"name":"locale-currency","version":"0.0.2","author":{"name":"Thomas Deegan","email":"tadeegan@gmail.com"},"license":"BSD-2-Clause","_id":"locale-currency@0.0.2","maintainers":[{"name":"tadeegan","email":"tadeegan@gmail.com"}],"homepage":"https://github.com/tadeegan/locale-currency#readme","bugs":{"url":"https://github.com/tadeegan/locale-currency/issues"},"dist":{"shasum":"e2c90607563ce47a59f9559e45a70e24e4db4b6d","tarball":"https://registry.npmjs.org/locale-currency/-/locale-currency-0.0.2.tgz","integrity":"sha512-5uUCVWBhixSV9x48yONxyGaW7YNGwFqM3f0ue1V+GbcHXGfOLKP+2HrwSFxkQ59V7cgcxahkRLD2Lw/CRfBJAQ==","signatures":[{"sig":"MEYCIQCl5BeO4O0ji08xzt2PqRL9mL9N3QUUZ85WglwEMIeDwwIhAJOwYuAa5uU1D04XHlVpRAVeX5gPsG3G0GE0uXvhuIOl","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","types":"./index.d.ts","_shasum":"e2c90607563ce47a59f9559e45a70e24e4db4b6d","gitHead":"e3573c18e6a9032de036f14b493fce4cd6eaaa41","scripts":{"test":"node test.js"},"_npmUser":{"name":"tadeegan","email":"tadeegan@gmail.com"},"repository":{"url":"git+https://github.com/tadeegan/locale-currency.git","type":"git"},"_npmVersion":"4.0.5","description":"A map of i18n country codes to ISO 4217 currency codes.  Originally generated from the output of java.util.Currency.getInstance(locale)","_nodeVersion":"7.4.0","dependencies":{},"_npmOperationalInternal":{"tmp":"tmp/locale-currency-0.0.2.tgz_1510513158571_0.3356250743381679","host":"s3://npm-registry-packages"},"directories":{}},"0.0.4":{"name":"locale-currency","version":"0.0.4","author":{"name":"Thomas Deegan","email":"tadeegan@gmail.com"},"license":"BSD-2-Clause","_id":"locale-currency@0.0.4","maintainers":[{"name":"tadeegan","email":"tadeegan@gmail.com"}],"homepage":"https://github.com/tadeegan/locale-currency#readme","bugs":{"url":"https://github.com/tadeegan/locale-currency/issues"},"dist":{"shasum":"f432aa7283c596f6fbd3354376ad92348228e507","tarball":"https://registry.npmjs.org/locale-currency/-/locale-currency-0.0.4.tgz","fileCount":8,"integrity":"sha512-S3pRVxU7xZDFlN4DkvLChQf8e1xm39XD6gkiWk1GI7nP3P7VMXHTWD/ZLLr13rAKNRpAeNCgTTMMNxEG8GZYRQ==","signatures":[{"sig":"MEQCIHfcqtDCGe0erzIJqGUtj2hzkSNIGl/rXSZIBJbXwTJ3AiAROom383rhc0U/msAGTOg4weB7D9geBHkPl7p6FzYMow==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7857},"main":"index.js","types":"./index.d.ts","gitHead":"7be9109b9a85be6e722c530d104c3edc6da01588","scripts":{"test":"node test.js"},"_npmUser":{"name":"tadeegan","email":"tadeegan@gmail.com"},"repository":{"url":"git+https://github.com/tadeegan/locale-currency.git","type":"git"},"_npmVersion":"10.9.0","description":"A map of i18n country codes to ISO 4217 currency codes.  Originally generated from the output of java.util.Currency.getInstance(locale)","directories":{},"_nodeVersion":"23.3.0","dependencies":{},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/locale-currency_0.0.4_1736202605816_0.3382877202481953","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"locale-currency","version":"1.0.0","description":"A map of locale codes to ISO 4217 currency codes. Supports BCP 47, i18n, and ISO 3166-1 alpha-2 formats.","type":"module","main":"index.js","types":"./index.d.ts","exports":{".":{"import":"./index.js","require":"./index.js","types":"./index.d.ts"}},"scripts":{"test":"node test.js && npm run test:types && npm run test:cjs","test:types":"tsc --noEmit","test:cjs":"node test-cjs.cjs"},"keywords":["locale","currency","i18n","internationalization","BCP 47","ISO 4217","ISO 3166-1","country code"],"author":{"name":"Thomas Deegan","email":"tadeegan@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/tadeegan/locale-currency.git"},"license":"BSD-2-Clause","engines":{"node":">=14.0.0"},"devDependencies":{"@types/node":"^24.6.0","typescript":"^5.9.2"},"_id":"locale-currency@1.0.0","gitHead":"8a201232ff33b660969f300e9b4a30e5abe076e7","bugs":{"url":"https://github.com/tadeegan/locale-currency/issues"},"homepage":"https://github.com/tadeegan/locale-currency#readme","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-OPw/KpjqAQdk36fbBHzJxPVpFx7DGU4jFYjmJoinkvbgS/QeKtsykiXszgS/EB458eieVppo/gbP1CbtJN4E9g==","shasum":"c45b0e0b2535b40aab7c140a90d7b96177ba91af","tarball":"https://registry.npmjs.org/locale-currency/-/locale-currency-1.0.0.tgz","fileCount":6,"unpackedSize":10228,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCiXvIjQWNV8i8c3KzsBkYB0U9tTRCHCuYyKCHK8OZchgIgCAEsxOaNq5F7Gq3tqFcmVWnmnSnM3AWF9cbMy8luF8A="}]},"_npmUser":{"name":"tadeegan","email":"tadeegan@gmail.com"},"directories":{},"maintainers":[{"name":"tadeegan","email":"tadeegan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/locale-currency_1.0.0_1759261934658_0.9049651192810413"},"_hasShrinkwrap":false}},"time":{"created":"2016-04-03T22:03:48.156Z","modified":"2025-09-30T19:52:15.019Z","0.0.1":"2016-04-03T22:03:48.156Z","0.0.2":"2017-11-12T18:59:18.688Z","0.0.4":"2025-01-06T22:30:06.038Z","1.0.0":"2025-09-30T19:52:14.836Z"},"bugs":{"url":"https://github.com/tadeegan/locale-currency/issues"},"author":{"name":"Thomas Deegan","email":"tadeegan@gmail.com"},"license":"BSD-2-Clause","homepage":"https://github.com/tadeegan/locale-currency#readme","repository":{"type":"git","url":"git+https://github.com/tadeegan/locale-currency.git"},"description":"A map of locale codes to ISO 4217 currency codes. Supports BCP 47, i18n, and ISO 3166-1 alpha-2 formats.","maintainers":[{"name":"tadeegan","email":"tadeegan@gmail.com"}],"readme":"# locale-currency\n\nA map of locale codes to ISO 4217 currency codes. Supports **BCP 47**, **i18n**, and **ISO 3166-1 alpha-2** locale formats.\n\n## Supported Formats\n\n- **BCP 47** language tags (e.g., `zh-Hant-TW`, `en-US`, `pt-BR`)\n- **i18n** locale codes with underscores (e.g., `en_US`, `zh_TW`)\n- **ISO 3166-1 alpha-2** country codes (e.g., `US`, `GB`, `TW`)\n\nThe library intelligently extracts the country/region code from complex locale strings to determine the appropriate currency.\n\n## Installation\n\n```bash\nnpm install locale-currency\n```\n\n## Usage\n\n### ES Modules (recommended)\n\n```javascript\nimport { getCurrency, getLocales } from 'locale-currency';\n\n// Get currency for a locale\ngetCurrency('US');           // 'USD'\ngetCurrency('en-US');        // 'USD'\ngetCurrency('en_US');        // 'USD'\ngetCurrency('zh-Hant-TW');   // 'TWD' - BCP 47 format\ngetCurrency('GB');           // 'GBP'\ngetCurrency('ES');           // 'EUR'\n\n// Get all countries that use a currency\nconst euroCountries = getLocales('EUR');\n// ['AD', 'AT', 'BE', 'CY', 'DE', 'EE', 'ES', 'FI', 'FR', 'GR', ...]\n```\n\n### CommonJS\n\n```javascript\nconst { getCurrency, getLocales } = require('locale-currency');\n\ngetCurrency('en-US'); // 'USD'\n```\n\n## API\n\n### `getCurrency(locale: string): string | null`\n\nReturns the ISO 4217 currency code for a given locale, or `null` if not found.\n\n- **Parameters:**\n  - `locale` - BCP 47, i18n, or ISO 3166-1 alpha-2 code\n- **Returns:** Currency code (e.g., `'USD'`, `'EUR'`) or `null`\n\n### `getLocales(currencyCode: string): string[]`\n\nReturns an array of ISO 3166-1 alpha-2 country codes that use the given currency.\n\n- **Parameters:**\n  - `currencyCode` - ISO 4217 currency code (e.g., `'USD'`, `'EUR'`)\n- **Returns:** Array of country codes\n\n## Examples\n\n```javascript\nimport { getCurrency, getLocales } from 'locale-currency';\n\n// Case insensitive\ngetCurrency('us');   // 'USD'\ngetCurrency('US');   // 'USD'\ngetCurrency('Us');   // 'USD'\n\n// i18n format with underscores\ngetCurrency('EN_US');  // 'USD'\ngetCurrency('en_us');  // 'USD'\n\n// BCP 47 format with hyphens\ngetCurrency('EN-US');  // 'USD'\ngetCurrency('en-us');  // 'USD'\n\n// Complex BCP 47 with script code\ngetCurrency('zh-Hant-TW');  // 'TWD' (Traditional Chinese in Taiwan)\ngetCurrency('zh-Hans-CN');  // 'CNY' (Simplified Chinese in China)\n\n// Direct country codes\ngetCurrency('GB');  // 'GBP'\ngetCurrency('ES');  // 'EUR'\ngetCurrency('GR');  // 'EUR'\n\n// Find countries using Euro\nconst euroCountries = getLocales('EUR');\nconsole.log(euroCountries.includes('GR'));  // true (Greece)\nconsole.log(euroCountries.includes('FR'));  // true (France)\nconsole.log(euroCountries.includes('ES'));  // true (Spain)\n```\n","readmeFilename":"README.md","keywords":["locale","currency","i18n","internationalization","BCP 47","ISO 4217","ISO 3166-1","country code"]}