@dazl/mostly-equal

中文文档
18.10.0发布于 2026/03/30MITES Module近 30 天下载 7972
原始使用文档
文档目录6 节
  1. mostly-equal package
  2. Example
  3. Functions
  4. Interfaces
  5. Variables
  6. Type Aliases

npm version @dazl/mostly-equal on Github

Home > @dazl/mostly-equal

mostly-equal package

Adds chai matches for partial equality of JSONs

Example

import * as chai from 'chai';
import { expect } from 'chai';
import { mostlyEqlChaiPlugin, notImportant } from '@dazl/mostly-equal';
chai.use(mostlyEqlChaiPlugin);
expect({ a: 1 }).to.mostlyEqual({
  a: 1,
  b: notImportant,
});

Functions

FunctionDescription
allowMarkersInFactory(f)
checkExpectValues(input, formatters)
clearMatchedValues(subMatcher)
defineSame(name, skipUndefined)Creates a symbol for usage in mostlyEqual, Comparing the resulting value in any place it is used as the value
defineUnique(name, skipUndefined)Creates a symbol for usage in expect.mostlyEqual, Comparing the resulting value in any place it is used as the value
equal(value, thumbsUpOnSuccess)Strict equality of a field
errorString(expected, actual, maxDepth, formatters, depth, path, passedMap, passedSet)
expectValue(expectMethod)Used for adding field matchers to mostlyEqual Creates a symbol used for field matching
expectValues(expectMethod, allowUndefined)Similar to expectValue(), but called for all the matches at once. This way a matcher can compare different values defineUnique()
getMatchedValues(expectValues)
HTMLFormatter(Element)
isExpectVal(val)
isExpectValues(val)
isGetter(target, key)
isPlainObj(value)
printPath(p)
registerChildSet(target, path, passedMap, passedSet)
safePrint(target, maxDepth, formatters, depth, passedMap, passedSet, path)
setGlobalOptions(maxDepth, formatters)
setSuiteOptions(before, after, options)
spaces(indent)

Interfaces

InterfaceDescription
ExpectValue
ExpectValues
ExpectValuesInfo
Formatter
MostlyEqualOptions
PseudoElement

Variables

VariableDescription
definedField must be defined (null is considered define)
expectValuesSymb
expectValueSymb
mostlyEqlChaiPlugin
notImportant
thumbsUp

Type Aliases

Type AliasDescription
AllowMarkers
AllowMarkersObj
ErrorOrText
ErrorOrTextOrExpect
ExpandedValues
ExpectMultiMatcher
ExpectSingleMatcher
LookupPath
MarkerSymbol
PseudoElementConstructor
UnknownObjectRecord

版本与发布记录

@dazl/mostly-equal 共发布 9 个版本,首次发布于 2025/08/28;过去 12 个月发布了 6 个版本。

版本发布日期距今
18.10.0latest2026/03/307 个月前
18.9.02026/03/307 个月前
18.8.02026/03/058 个月前
18.7.02026/01/229 个月前
18.6.12025/12/0111 个月前
18.6.02025/11/2011 个月前

关于 @dazl/mostly-equal 的常见问题

@dazl/mostly-equal 是什么?

@dazl/mostly-equal on Github

如何安装 @dazl/mostly-equal?

在项目目录运行 npm install @dazl/mostly-equal,或使用 pnpm add / yarn add / bun add。

@dazl/mostly-equal 支持 TypeScript 吗?

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

@dazl/mostly-equal 支持 ESM 还是 CommonJS?

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

@dazl/mostly-equal 可以商用吗?

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

@dazl/mostly-equal 的下载量有多少?

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

@dazl/mostly-equal 还在维护吗?

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