# @ac-dev/countries-service 中文文档

规范地址：https://npmcn.com/package/%40ac-dev/countries-service/

版本：1\.2\.0
npm 元数据更新时间：2022-04-04T11:04:37.777Z
中文译文更新时间：2026-11-06T00:44:12.096Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40ac-dev/countries-service
原文对照：https://npmcn.com/package/%40ac-dev/countries-service/?lang=original
项目主页：https://github.com/Randagio13/countries-service#readme
源码仓库：https://github.com/Randagio13/countries-service

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：228 kB，28 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=10
- 运行依赖：0 个
- 首次发布：2022-01-23T19:13:33.196Z
- 最新版本发布：2022-03-06T18:35:13.516Z
- 近 30 天下载量：7988（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

获取世界国家

## 安装

```sh
npm install @ac-dev/countries-service
```

也可以使用：`pnpm add @ac-dev/countries-service`、`yarn add @ac-dev/countries-service`、`bun add @ac-dev/countries-service`

## README

# 国家服务处

[![NPM](https://nodei.co/npm/@ac-dev/countries-service.png?compact=true)](https://nodei.co/npm/@ac-dev/countries-service/)  
[![](https://img.shields.io/npm/dt/@ac-dev/countries-service.svg?style=flat-square)](https://www.npmjs.com/package/@ac-dev/countries-service)

## 目录

1.  [特派团](https://npmcn.com/package/%40ac-dev/countries-service/#readme-mission)
2.  [开始](https://npmcn.com/package/%40ac-dev/countries-service/#readme-getting-started)
    -   [安装](https://npmcn.com/package/%40ac-dev/countries-service/#readme-installation)
    -   [导入](https://npmcn.com/package/%40ac-dev/countries-service/#readme-import)
3.  [使用量](https://npmcn.com/package/%40ac-dev/countries-service/#readme-usage)
4.  [贡献者](https://npmcn.com/package/%40ac-dev/countries-service/#readme-contributors)
5.  [需要帮助](https://npmcn.com/package/%40ac-dev/countries-service/#readme-need-help)
6.  [许可证](https://npmcn.com/package/%40ac-dev/countries-service/#readme-license)
7.  [发起人](https://npmcn.com/package/%40ac-dev/countries-service/#readme-sponsor)

## 特派团

-   我从未找到任何完整的图书馆来获取世界各国,州和城市. 我想开发最好的一个。 当然,欢迎贡献者!
-   我拿着这个 [数据](https://github.com/dr5hn/countries-states-cities-database) 作为起点.
-   此软件包是 [城市服务](https://github.com/Randagio13/countries-states-cities-service)

## 开始

要开始这个库,你需要安装它并添加到您的项目中.

### 安装

国家城市服务作为npm软件包提供.

```bash
# npm
npm install @ac-dev/countries-service

# yarn
yarn add @ac-dev/countries-service
```

### 导入

导入单个名称的导入如下 :

```typescript
import { Countries } from '@ac-dev/countries-service'
```

## 使用量

下面的代码片段显示如何付诸行动 `countries-service` 在某些常见情况下.

-   得到所有国家.

```typescript
const countries = Countries.getCountries()
```

-   让所有国家通过 `asc` 有点.

```typescript
const countries = Countries.getCountries({
  sort: {
    mode: 'asc',
  },
})
```

-   让所有国家通过 `desc` 有点.

```typescript
const countries = Countries.getCountries({
  sort: {
    mode: 'desc',
  },
})
```

-   按字母顺序排列所有国家.

```typescript
const countries = Countries.getCountries({
  sort: {
    mode: 'alphabetical',
    key: 'iso2',
  },
})
```

-   使所有国家实现本地化.

```typescript
const countries = Countries.getCountries({ locale: 'it' })
```

-   以同位素2代码获取一个国家.

```typescript
const countries = Countries.getCountries({ filters: { iso2: 'US' } })
```

-   通过同位素2代码和本地化获得一个国家.

```typescript
const countries = Countries.getCountries({
  filters: { iso2: 'IT' },
  locale: 'it',
})
```

-   以同位素3代码获取一个国家.

```typescript
const countries = Countries.getCountries({ filters: { iso3: 'ITA' } })
```

## 贡献者

感谢任何捐助。 您可以从以下步骤开始:

1.  叉头 [此寄存器](https://github.com/Randagio13/countries-states-cities-service) (学习如何做到这一点) [这里](https://help.github.com/articles/fork-a-repo)) (中文(简体) ).
    
2.  砍掉叉子仓库.
    
3.  更改并创建拉动请求( R)[学着怎么做](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request)) (中文(简体) ).
    
4.  我会处理你的拉拉请求 并提供一些反馈.
    

## 需要帮忙吗?

Pи [在推特上进行](https://twitter.com/randagio19)

## 许可证

此寄存器根据 [麻省理工学院](https://npmcn.com/package/%40ac-dev/countries-service/LICENSE) 执照.

## 发起人

别害羞

[:心脏:发起人](https://github.com/sponsors/Randagio13)

## 常见问题

### @ac-dev/countries-service 是什么？

获取世界国家

### 如何安装 @ac-dev/countries-service？

在项目目录运行 npm install @ac-dev/countries-service，或使用 pnpm add / yarn add / bun add。

### @ac-dev/countries-service 支持 TypeScript 吗？

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

### @ac-dev/countries-service 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @ac-dev/countries-service 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=10。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @ac-dev/countries-service 可以商用吗？

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

### @ac-dev/countries-service 的下载量有多少？

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

### @ac-dev/countries-service 还在维护吗？

最新版本 1\.2\.0 发布于 2022/03/07（4 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2022/01/24。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

