# deep-eql 中文文档

规范地址：https://npmcn.com/package/deep-eql/

版本：5\.0\.2
npm 元数据更新时间：2024-06-05T15:04:41.621Z
中文译文更新时间：2026-11-05T16:16:10.128Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/deep-eql
原文对照：https://npmcn.com/package/deep-eql/?lang=original
项目主页：https://github.com/chaijs/deep-eql#readme
源码仓库：https://github.com/chaijs/deep-eql

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

- 包体积（解压后）：23.9 kB，4 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：\>=6
- 运行依赖：0 个
- 首次发布：2013-09-18T15:48:42.366Z
- 最新版本发布：2024-06-03T08:03:16.644Z
- 近 30 天下载量：226535116（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：23（近 12 个月 0 个）

## 中文简介

改进了对Node.js和浏览器的深度平等测试.

## 安装

```sh
npm install deep-eql
```

也可以使用：`pnpm add deep-eql`、`yarn add deep-eql`、`bun add deep-eql`

## README

# [![deep-eql](https://raw.githubusercontent.com/chaijs/deep-eql/main/deep-eql-logo.svg)](http://chaijs.com/ "Chai Documentation")

改进对男女两性平等的深入测试 [节点](http://nodejs.org/) 和浏览器.

 [![build:?](https://github.com/chaijs/deep-eql/workflows/Build/badge.svg)](https://github.com/chaijs/deep-eql/actions)[![coverage:?](https://img.shields.io/coveralls/chaijs/deep-eql/master.svg?style=flat-square) ](https://coveralls.io/r/chaijs/deep-eql)[![dependencies:?](https://img.shields.io/npm/dm/deep-eql.svg?style=flat-square) ](https://www.npmjs.com/packages/deep-eql)![devDependencies:?](https://img.shields.io/david/chaijs/deep-eql.svg?style=flat-square)  
 [![Join the Slack chat](https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square)](https://chai-slack.herokuapp.com/)[![Join the Gitter chat](https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square)](https://gitter.im/chaijs/deep-eql)

## 什么是"深爱"?

深处 Eql是一个模块,您可以用来确定两个对象是否"深度"平等,也就是说,它不是具有偏好平等性(`a === b`),这个模块会递归检查对象的密钥,直到它找到原始人来检查偏好平等. 在JavaScript中将更多关于平等的内容改为 [关于 mdn 的比较操作员文章](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators)。 。 。 .

举例来说,如下:

```js
1 === 1 // These are primitives, they hold the same reference - they are strictly equal
1 == '1' // These are two different primitives, through type coercion they hold the same value - they are loosely equal
{ a: 1 } !== { a: 1 } // These are two different objects, they hold different references and so are not strictly equal - even though they hold the same values inside
{ a: 1 } != { a: 1 } // They have the same type, meaning loose equality performs the same check as strict equality - they are still not equal.

var deepEql = require("deep-eql");
deepEql({ a: 1 }, { a: 1 }) === true // deepEql can determine that they share the same keys and those keys share the same values, therefore they are deeply equal!
```

## 安装

### 节点.js

`deep-eql` 可在 [无](http://npmjs.org/)。 。 。 .

```
$ npm install deep-eql
```

## 使用量

二. 主要出口 `deep-eql` 是可给予两个对象比较的函数。 它总是会返回一个布尔,可以用来确定两个对象是否非常等同.

### 规则

-   严格实现不可逆节点的平等 [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)数字 :
    -   `eql(NaN, NaN).should.be.true;`
    -   `eql(-0, +0).should.be.false;`
-   所有拥有和继承的可拥有财产都被视为:
    -   `eql(Object.create({ foo: { a: 1 } }), Object.create({ foo: { a: 1 } })).should.be.true;`
    -   `eql(Object.create({ foo: { a: 1 } }), Object.create({ foo: { a: 2 } })).should.be.false;`
-   比较时 `Error` 对象,仅限 `name`, (中文(简体) ), `message`,以及 `code` 属性被考虑,而不论是否具有:
    -   `eql(Error('foo'), Error('foo')).should.be.true;`
    -   `eql(Error('foo'), Error('bar')).should.be.false;`
    -   `eql(Error('foo'), TypeError('foo')).should.be.false;`
    -   `eql(Object.assign(Error('foo'), { code: 42 }), Object.assign(Error('foo'), { code: 42 })).should.be.true;`
    -   `eql(Object.assign(Error('foo'), { code: 42 }), Object.assign(Error('foo'), { code: 13 })).should.be.false;`
    -   `eql(Object.assign(Error('foo'), { otherProp: 42 }), Object.assign(Error('foo'), { otherProp: 13 })).should.be.true;`
-   参数不是参数 :
    -   `eql([], arguments).should.be.false;`
    -   `eql([], Array.prototype.slice.call(arguments)).should.be.true;`

## 常见问题

### deep-eql 是什么？

改进了对Node\.js和浏览器的深度平等测试\.

### 如何安装 deep-eql？

在项目目录运行 npm install deep-eql，或使用 pnpm add / yarn add / bun add。

### deep-eql 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/deep-eql 是否存在。

### deep-eql 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### deep-eql 需要什么版本的 Node\.js？

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

### deep-eql 可以商用吗？

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

### deep-eql 的下载量有多少？

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

### deep-eql 还在维护吗？

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

