@aerapass/country-data

中文文档
1.1.1发布于 2026/01/26MITTypeScriptCommonJS近 30 天下载 2359

Data about countries - like their ISO codes and currencies

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. Countries
  4. Status notes
  5. Regions
  6. Currencies
  7. Sources

Country Data

npm Main CI codecov code style: prettier semantic-release GitHub

Data about countries - like their ISO codes and currencies - with typings.

Installation

npm install @aerapass/country-data

Usage

import { countries, continents, currencies, regions } from '@aerapass/country-data'

// .all gives you an array of all entries
console.log(countries.all)
console.log(currencies.all)

// countries are found using alpha2 or alpha3 (both uppercase)
console.log(countries.BE.name) // 'Belgium'
console.log(countries.FRA.currencies) // ['EUR']

// currencies are accessed by their code (uppercase)
console.log(currencies.USD.name) // 'United States Dollar'

// regions are accessed using a camel case name
console.log(regions.europe.countries)

Countries

The data currently provided for each country is:

Status notes

The status can be one of 'assigned', 'reserved', 'user assigned' or 'deleted'.

Assigned means that the code is properly in the ISO 3166 standard. Reserved means that the code is being prevented from being used. Deleted means that it has been deleted. User Assigned means that for some use cases it is required. Deleted means that it used to be in the standard but is now not.

See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for full details, especially the "User-assigned code elements" and "Reserved code elements" sections.

Regions

Countries are ofter grouped into regions. The list of regions is by no means exhaustive, pull requests very welcome for additions.

  • countries An array of alpha2 codes for the countries in this region.

Currencies

It is not that useful to just have the currency code(s) for a country, so included is currency data too:

  • name The english name for the currency
  • code The ISO 4217 code
  • number The ISO 4217 number
  • decimals The number of decimal digits conventionally shown
  • symbol The currency symbol for the currency (e.g. ¥, $ etc.). Some symbols are not available, in which case symbol contains the ISO 4217 code. Credit to bengourley/currency-symbol-map for the symbol database.

Sources

The currency data was copied from the Wikipedia ISO 4217 page.

The country calling codes came from the Wikipedia country calling codes page.

版本与发布记录

@aerapass/country-data 共发布 6 个版本,首次发布于 2020/07/09;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.1.1latest2026/01/269 个月前
1.0.52021/02/145 年前
1.0.42021/01/285 年前
1.0.32020/10/216 年前
1.0.22020/07/096 年前
1.0.12020/07/096 年前

关于 @aerapass/country-data 的常见问题

@aerapass/country-data 是什么?

Data about countries - like their ISO codes and currencies

如何安装 @aerapass/country-data?

在项目目录运行 npm install @aerapass/country-data,或使用 pnpm add / yarn add / bun add。

@aerapass/country-data 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aerapass/country-data 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@aerapass/country-data 可以商用吗?

@aerapass/country-data 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aerapass/country-data 的下载量有多少?

根据 npm 官方下载统计,@aerapass/country-data 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,359 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aerapass/country-data 还在维护吗?

最新版本 1.1.1 发布于 2026/01/26(9 个月前);至今共发布 6 个版本,其中过去 12 个月发布了 1 个;首次发布于 2020/07/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。