deep-eql

中文文档
5.0.2发布于 2024/06/03MITES Module零依赖近 30 天下载 2.3亿

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

中文使用文档
文档目录5 节
  1. 什么是"深爱"?
  2. 安装
  3. 节点.js
  4. 使用量
  5. 规则

deep-eql

改进对男女两性平等的深入测试 节点 和浏览器.

build:? coverage:? dependencies:? devDependencies:?
Join the Slack chat Join the Gitter chat

什么是"深爱"?

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

举例来说,如下:

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 可在 无。 。 。 .

$ npm install deep-eql

使用量

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

规则

  • 严格实现不可逆节点的平等 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 共发布 23 个版本,首次发布于 2013/09/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.1.4legacy2024/06/052 年前
5.0.2latest2024/06/032 年前
5.0.12023/10/253 年前
5.0.02023/10/183 年前
4.1.32022/12/053 年前
4.1.22022/11/073 年前

关于 deep-eql 的常见问题

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 和提交记录判断。