@vitest/utils
Advanced tools
Comparing version 3.0.0-beta.3 to 3.0.0-beta.4
@@ -92,3 +92,3 @@ import { D as DiffOptions } from './types-6R1G1gkS.js'; | ||
declare function diff(a: any, b: any, options?: DiffOptions): string | undefined; | ||
declare function printDiffOrStringify(expected: unknown, received: unknown, options?: DiffOptions): string | undefined; | ||
declare function printDiffOrStringify(received: unknown, expected: unknown, options?: DiffOptions): string | undefined; | ||
declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<WeakKey>, expectedReplaced?: WeakSet<WeakKey>): { | ||
@@ -95,0 +95,0 @@ replacedActual: any; |
@@ -51,2 +51,3 @@ import { PrettyFormatOptions } from '@vitest/pretty-format'; | ||
clearImmediate: typeof clearImmediate; | ||
queueMicrotask: typeof queueMicrotask; | ||
} | ||
@@ -53,0 +54,0 @@ declare function getSafeTimers(): SafeTimers; |
@@ -610,3 +610,4 @@ import { g as getDefaultExportFromCjs } from './chunk-_commonjsHelpers.js'; | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
clearImmediate: safeClearImmediate, | ||
queueMicrotask: safeQueueMicrotask | ||
} = globalThis[SAFE_TIMERS_SYMBOL] || globalThis; | ||
@@ -621,3 +622,4 @@ const { nextTick: safeNextTick } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || { nextTick: (cb) => cb() }; | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
clearImmediate: safeClearImmediate, | ||
queueMicrotask: safeQueueMicrotask | ||
}; | ||
@@ -632,3 +634,4 @@ } | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
clearImmediate: safeClearImmediate, | ||
queueMicrotask: safeQueueMicrotask | ||
} = globalThis; | ||
@@ -645,3 +648,4 @@ const { nextTick: safeNextTick } = globalThis.process || { | ||
setImmediate: safeSetImmediate, | ||
clearImmediate: safeClearImmediate | ||
clearImmediate: safeClearImmediate, | ||
queueMicrotask: safeQueueMicrotask | ||
}; | ||
@@ -648,0 +652,0 @@ globalThis[SAFE_TIMERS_SYMBOL] = timers; |
@@ -63,2 +63,17 @@ import { ErrorWithDiff, ParsedStack } from './types.js'; | ||
}; | ||
type EachMapping = { | ||
generatedLine: number; | ||
generatedColumn: number; | ||
source: null; | ||
originalLine: null; | ||
originalColumn: null; | ||
name: null; | ||
} | { | ||
generatedLine: number; | ||
generatedColumn: number; | ||
source: string | null; | ||
originalLine: number; | ||
originalColumn: number; | ||
name: string | null; | ||
}; | ||
declare abstract class SourceMap { | ||
@@ -104,2 +119,6 @@ version: SourceMapV3['version']; | ||
declare function generatedPositionFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping | InvalidGeneratedMapping; | ||
/** | ||
* Iterates each mapping in generated position order. | ||
*/ | ||
declare function eachMapping(map: TraceMap, cb: (mapping: EachMapping) => void): void; | ||
@@ -119,2 +138,2 @@ interface StackTraceParserOptions { | ||
export { type SourceMapInput, type StackTraceParserOptions, TraceMap, createStackString, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace }; | ||
export { type EachMapping, type SourceMapInput, type StackTraceParserOptions, TraceMap, createStackString, eachMapping, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace }; |
@@ -615,2 +615,36 @@ import { notNullish, isPrimitive } from './helpers.js'; | ||
} | ||
/** | ||
* Iterates each mapping in generated position order. | ||
*/ | ||
function eachMapping(map, cb) { | ||
const decoded = decodedMappings(map); | ||
const { names, resolvedSources } = map; | ||
for (let i = 0; i < decoded.length; i++) { | ||
const line = decoded[i]; | ||
for (let j = 0; j < line.length; j++) { | ||
const seg = line[j]; | ||
const generatedLine = i + 1; | ||
const generatedColumn = seg[0]; | ||
let source = null; | ||
let originalLine = null; | ||
let originalColumn = null; | ||
let name = null; | ||
if (seg.length !== 1) { | ||
source = resolvedSources[seg[1]]; | ||
originalLine = seg[2] + 1; | ||
originalColumn = seg[3]; | ||
} | ||
if (seg.length === 5) | ||
name = names[seg[4]]; | ||
cb({ | ||
generatedLine, | ||
generatedColumn, | ||
source, | ||
originalLine, | ||
originalColumn, | ||
name, | ||
}); | ||
} | ||
} | ||
} | ||
function OMapping(source, line, column, name) { | ||
@@ -695,2 +729,3 @@ return { source, line, column, name }; | ||
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/; | ||
globalThis.process?.platform === "win32" ? ";" : ":"; | ||
function cwd() { | ||
@@ -960,2 +995,2 @@ if (typeof process !== "undefined" && typeof process.cwd === "function") { | ||
export { TraceMap, createStackString, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace }; | ||
export { TraceMap, createStackString, eachMapping, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace }; |
{ | ||
"name": "@vitest/utils", | ||
"type": "module", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.4", | ||
"description": "Shared Vitest utility functions", | ||
@@ -65,3 +65,3 @@ "license": "MIT", | ||
"tinyrainbow": "^1.2.0", | ||
"@vitest/pretty-format": "3.0.0-beta.3" | ||
"@vitest/pretty-format": "3.0.0-beta.4" | ||
}, | ||
@@ -68,0 +68,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
159870
4573
+ Added@vitest/pretty-format@3.0.0-beta.4(transitive)
- Removed@vitest/pretty-format@3.0.0-beta.3(transitive)