MCPcopy
hub / github.com/vitest-dev/vitest / comparePrimitive

Function comparePrimitive

packages/utils/src/diff/index.ts:155–166  ·  view source on GitHub ↗
(
  a: number | boolean,
  b: number | boolean,
  options?: DiffOptions,
  memorize: Memorize = DEFAULT_MEMORIZE,
)

Source from the content-addressed store, hash-verified

153}
154
155function comparePrimitive(
156 a: number | boolean,
157 b: number | boolean,
158 options?: DiffOptions,
159 memorize: Memorize = DEFAULT_MEMORIZE,
160) {
161 const aFormat = memorize('expected', prettyFormat(a, FORMAT_OPTIONS))
162 const bFormat = memorize('actual', prettyFormat(b, FORMAT_OPTIONS))
163 return aFormat === bFormat
164 ? ''
165 : diffLinesUnified(aFormat.split('\n'), bFormat.split('\n'), options)
166}
167
168function sortMap(map: Map<unknown, unknown>) {
169 return new Map(Array.from(map.entries()).sort())

Callers 1

diffFunction · 0.85

Calls 1

diffLinesUnifiedFunction · 0.90

Tested by

no test coverage detected