# @achingbrain/ip-address 中文文档

规范地址：https://npmcn.com/package/%40achingbrain/ip-address/

版本：8\.1\.0
npm 元数据更新时间：2022-04-04T11:10:59.298Z
中文译文更新时间：2026-11-05T22:47:21.238Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40achingbrain/ip-address
原文对照：https://npmcn.com/package/%40achingbrain/ip-address/?lang=original
项目主页：https://github.com/beaugunderson/ip-address#readme
源码仓库：https://github.com/beaugunderson/ip-address

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

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

## 中文简介

在节点和浏览器中解析IPv4和IPv6 IP地址的库.

## 安装

```sh
npm install @achingbrain/ip-address
```

也可以使用：`pnpm add @achingbrain/ip-address`、`yarn add @achingbrain/ip-address`、`bun add @achingbrain/ip-address`

## README

# 临时叉子 [ip-地址](https://www.npmjs.com/package/ip-address) 与 [148号](https://github.com/beaugunderson/ip-address/pull/148) 应用

[![travis](https://img.shields.io/travis/beaugunderson/ip-address.svg)](http://travis-ci.com/beaugunderson/ip-address) [![codecov](https://codecov.io/github/beaugunderson/ip-address/coverage.svg?branch=master)](https://codecov.io/github/beaugunderson/ip-address?branch=master) [![downloads](https://img.shields.io/npm/dm/ip-address.svg)](https://www.npmjs.com/package/ip-address) [![npm](https://img.shields.io/npm/v/ip-address.svg)](https://www.npmjs.com/package/ip-address) [![snyk](https://snyk.io/test/github/beaugunderson/ip-address/badge.svg)](https://snyk.io/test/github/beaugunderson/ip-address)

## ip-地址

`ip-address` 是用于验证和操纵 IPv4 和 IPv6 的库 地址在 JavaScript 中.

### 从 6. x 迁移到 7. x

`ip-address` 在TypeScript中被改写为版本7. 如果你在用的话 第6版 您需要做这些修改才能升级:

-   而不是检查 `isValid()`,它已经删除, 你需要使用一个 `try`编号 :`catch` 如果你接受未知输入。 这使得类型脚本 类型和允许使用 `AddressError` 包含一个 `parseMessage` 如果在解析中发生错误 步骤.
-   而不是使用 `error`, (中文(简体) ), `parseError`,以及 `valid` 属性 需要使用 `message` 财务报告和审定财务报表 `parseMessage` 掷出 `AddressError`。 。 。 .

### 文档

文件备查 [页面存档备份,存于互联网档案馆 p-address.js.org](http://ip-address.js.org/)。 。 。 .

### 实例

```js
var Address6 = require('ip-address').Address6;

var address = new Address6('2001:0:ce49:7601:e866:efff:62c3:fffe');

var teredo = address.inspectTeredo();

teredo.client4;    // '157.60.0.1'
```

### 特征

-   可通过共同JS或无害环境管理使用
-   分析所有 IPv6 标记
-   从 URL 解析 IPv6 地址和端口 `Address6.fromURL(url)`
-   有效性检查
-   解码 [泰雷多语Name 资料](http://en.wikipedia.org/wiki/Teredo_tunneling#IPv6_addressing) 在一个地址中
-   一个地址是否是另一个地址的有效子网
-   给定地址有什么特殊属性( 多播前缀, 独一无二 ) 本地地址前缀等)
-   给定地址中一定大小的子网数
-   显示方法
    -   十六进制 二进制和小数
    -   条形
    -   正确的窗体
    -   IPv4兼容(即. `::ffff:192.168.0.1`(中文(简体) )
-   在职 [节点](http://nodejs.org/) 和浏览器(带有浏览器)
-   ~1 600个测试病例

### 用于

-   [肛门](https://github.com/edsu/anon) 哪些权力 [@ 国会](https://twitter.com/congressedits)中间 [其他许多](https://github.com/edsu/anon#community)
-   [基础85](https://github.com/noseglid/base85): 基数85 编码/解码
-   [反网络核心](https://github.com/Juniper/contrail-web-core)编号: Contrail,由Juniper网络制造的网络虚拟化解决方案
-   [日记](https://github.com/apaprocki/node-dhcpjs): DHCP 客户端和服务器
-   [划时代](https://github.com/epochtalk/epochtalk): 下一代论坛 软件
-   [地理网络](https://github.com/tfrce/node-geoip-web): 用于 快速地理定位 IP 地址
-   [六节车厢](https://github.com/mysmartgrid/hexabus): 一个基于IPv6的家 自动化总线
-   [调动](https://github.com/atmos/hubot-deploy): GitHub 通过hupot 流动
-   [光学扫描器](https://github.com/robison/heroku-portscanner)数字图 在赫鲁库举行
-   [ip-sswarm (英语)](https://github.com/diasdavid/node-ipfs-swarm): 一团 根据森林小组和森林小组
-   [javascript- x 服务器](https://github.com/GothAck/javascript-x-server): 一个 X 用 JavaScript 编写的服务器
-   [图像](https://github.com/jas-/node-libnmap): nmap 的节点 API
-   [邮箱](https://github.com/mofux/mail-io): 轻量级 SMTP 服务器
-   [最大读取器](https://github.com/PaddeK/node-maxmind-db): 用于 读取 MaxMind 数据库文件
-   [代理代理- protocol- v2](https://github.com/ably/proxy-protocol-v2): 代理服务器 协议编码器/解码器由 [亚伯利](https://www.ably.io/)
-   [萨姆萨拉](https://github.com/mariusGundersen/Samsara): 一个 Docker 网页界面
-   [小亚细亚](https://github.com/sis-cmdb/sis-api): 配置管理 数据库 API
-   [袜子5客户端](https://github.com/mattcg/socks5-client): 一个 SOCKS v5 客户端
-   [袜子化](https://github.com/vially/node-socksified): 一个 SOCKS v5 客户端
-   [袜子v5](https://github.com/mscdex/socksv5): 一个 SOCKS v5 服务器/客户端
-   [斯达皮语name](https://github.com/rsolomou/ssdapi): 由 波特斯茅斯大学
-   [SwitchyOmega (英语)](https://github.com/FelisCatus/SwitchyOmega)(单位:千美元) [颜色 扩展](https://chrome.google.com/webstore/detail/padekgcemlokbadohgkifijomclgjgif) 用于在多个代理用户之间切换 ~311k !
-   [宽度](https://github.com/racker/node-swiz): 建立序列化框架 用于 [空格空间](http://www.rackspace.com/)

## 常见问题

### @achingbrain/ip-address 是什么？

在节点和浏览器中解析IPv4和IPv6 IP地址的库\.

### 如何安装 @achingbrain/ip-address？

在项目目录运行 npm install @achingbrain/ip-address，或使用 pnpm add / yarn add / bun add。

### @achingbrain/ip-address 支持 TypeScript 吗？

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

### @achingbrain/ip-address 支持 ESM 还是 CommonJS？

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

### @achingbrain/ip-address 需要什么版本的 Node\.js？

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

### @achingbrain/ip-address 可以商用吗？

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

### @achingbrain/ip-address 的下载量有多少？

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

### @achingbrain/ip-address 还在维护吗？

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

