Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vitest/utils

Package Overview
Dependencies
Maintainers
4
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitest/utils - npm Package Compare versions

Comparing version 1.6.0 to 2.0.0-beta.1

dist/types-DyShQl4f.d.ts

4

dist/chunk-display.js

@@ -49,3 +49,3 @@ import { format as format$1, plugins } from 'pretty-format';

for (let i2 = 0; i2 < args.length; i2++)
objects.push(inspect(args[i2], { depth: 0, colors: false, compact: 3 }));
objects.push(inspect(args[i2], { depth: 0, colors: false }));
return objects.join(" ");

@@ -69,3 +69,3 @@ }

if (typeof value === "object" && value !== null)
return inspect(value, { depth: 0, colors: false, compact: 3 });
return inspect(value, { depth: 0, colors: false });
return String(value);

@@ -72,0 +72,0 @@ }

@@ -1,3 +0,3 @@

import { D as DiffOptions } from './types-9l4niLY8.js';
export { a as DiffOptionsColor } from './types-9l4niLY8.js';
import { D as DiffOptions } from './types-DyShQl4f.js';
export { a as DiffOptionsColor } from './types-DyShQl4f.js';
import 'pretty-format';

@@ -4,0 +4,0 @@

@@ -1,6 +0,6 @@

import { D as DiffOptions } from './types-9l4niLY8.js';
import { D as DiffOptions } from './types-DyShQl4f.js';
import 'pretty-format';
declare function serializeError(val: any, seen?: WeakMap<WeakKey, any>): any;
declare function processError(err: any, diffOptions?: DiffOptions): any;
declare function processError(err: any, diffOptions?: DiffOptions, seen?: WeakSet<WeakKey>): any;
declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<WeakKey>, expectedReplaced?: WeakSet<WeakKey>): {

@@ -7,0 +7,0 @@ replacedActual: any;

@@ -77,3 +77,3 @@ import { diff } from './diff.js';

}
function processError(err, diffOptions) {
function processError(err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
if (!err || typeof err !== "object")

@@ -98,7 +98,12 @@ return { message: err };

err.message = normalizeErrorMessage(err.message);
if (typeof err.cause === "object" && typeof err.cause.message === "string")
err.cause.message = normalizeErrorMessage(err.cause.message);
} catch {
}
try {
if (!seen.has(err) && typeof err.cause === "object") {
seen.add(err);
err.cause = processError(err.cause, diffOptions, seen);
}
} catch {
}
try {
return serializeError(err);

@@ -105,0 +110,0 @@ } catch (e) {

@@ -64,4 +64,3 @@ function notNullish(v) {

seen.set(val, out);
while (k--)
out[k] = clone(val[k], seen, options);
while (k--) out[k] = clone(val[k], seen, options);
return out;

@@ -68,0 +67,0 @@ }

@@ -22,17 +22,17 @@ export { DeferPromise, assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray } from './helpers.js';

interface LoupeOptions {
showHidden?: boolean | undefined;
depth?: number | null | undefined;
colors?: boolean | undefined;
customInspect?: boolean | undefined;
showProxy?: boolean | undefined;
maxArrayLength?: number | null | undefined;
maxStringLength?: number | null | undefined;
breakLength?: number | undefined;
compact?: boolean | number | undefined;
sorted?: boolean | ((a: string, b: string) => number) | undefined;
getters?: 'get' | 'set' | boolean | undefined;
numericSeparator?: boolean | undefined;
truncate?: number;
type Inspect = (value: unknown, options: Options) => string;
interface Options {
showHidden: boolean;
depth: number;
colors: boolean;
customInspect: boolean;
showProxy: boolean;
maxArrayLength: number;
breakLength: number;
truncate: number;
seen: unknown[];
inspect: Inspect;
stylize: (value: string, styleType: string) => string;
}
type LoupeOptions = Partial<Options>;
declare function format(...args: unknown[]): string;

@@ -39,0 +39,0 @@ declare function inspect(obj: unknown, options?: LoupeOptions): string;

@@ -17,2 +17,3 @@ import { ParsedStack, ErrorWithDiff } from './types.js';

version: 3;
ignoreList?: number[];
}

@@ -46,3 +47,8 @@ interface EncodedSourceMap extends SourceMapV3 {

type Bias = typeof GREATEST_LOWER_BOUND | typeof LEAST_UPPER_BOUND;
type SourceMapInput = string | Ro<EncodedSourceMap> | Ro<DecodedSourceMap> | TraceMap;
type XInput = {
x_google_ignoreList?: SourceMapV3['ignoreList'];
};
type EncodedSourceMapXInput = EncodedSourceMap & XInput;
type DecodedSourceMapXInput = DecodedSourceMap & XInput;
type SourceMapInput = string | EncodedSourceMapXInput | DecodedSourceMapXInput | TraceMap;
type Needle = {

@@ -67,21 +73,8 @@ line: number;

resolvedSources: SourceMapV3['sources'];
ignoreList: SourceMapV3['ignoreList'];
}
type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
type RoArray<T> = Ro<T>[];
type RoObject<T> = {
[K in keyof T]: T[K] | Ro<T[K]>;
};
declare const LEAST_UPPER_BOUND = -1;
declare const GREATEST_LOWER_BOUND = 1;
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
declare let originalPositionFor: (map: TraceMap, needle: Needle) => OriginalMapping | InvalidOriginalMapping;
/**
* Finds the generated line/column position of the provided source/line/column source position.
*/
declare let generatedPositionFor: (map: TraceMap, needle: SourceNeedle) => GeneratedMapping | InvalidGeneratedMapping;
declare class TraceMap implements SourceMap {

@@ -94,2 +87,3 @@ version: SourceMapV3['version'];

sourcesContent: SourceMapV3['sourcesContent'];
ignoreList: SourceMapV3['ignoreList'];
resolvedSources: string[];

@@ -103,2 +97,12 @@ private _encoded;

}
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
declare function originalPositionFor(map: TraceMap, needle: Needle): OriginalMapping | InvalidOriginalMapping;
/**
* Finds the generated line/column position of the provided source/line/column source position.
*/
declare function generatedPositionFor(map: TraceMap, needle: SourceNeedle): GeneratedMapping | InvalidGeneratedMapping;

@@ -105,0 +109,0 @@ interface StackTraceParserOptions {

import { notNullish, isPrimitive } from './helpers.js';
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
function normalizeWindowsPath(input = "") {
if (!input || !input.includes("\\")) {
if (!input) {
return input;
}
return input.replace(/\\/g, "/");
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
}
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
function cwd() {
if (typeof process !== "undefined") {
if (typeof process !== "undefined" && typeof process.cwd === "function") {
return process.cwd().replace(/\\/g, "/");

@@ -587,4 +588,5 @@ }

// indexes before we find where we need to insert.
const index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
insert(originalLine, (memo.lastIndex = index + 1), [sourceColumn, i, seg[COLUMN]]);
let index = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
memo.lastIndex = ++index;
insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
}

@@ -613,16 +615,2 @@ }

const GREATEST_LOWER_BOUND = 1;
/**
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
*/
let decodedMappings;
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
let originalPositionFor;
/**
* Finds the generated line/column position of the provided source/line/column source position.
*/
let generatedPositionFor;
class TraceMap {

@@ -641,2 +629,3 @@ constructor(map, mapUrl) {

this.sourcesContent = sourcesContent;
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
const from = resolve(sourceRoot || '', stripFilename(mapUrl));

@@ -658,56 +647,50 @@ this.resolvedSources = sources.map((s) => resolve(s || '', from));

}
(() => {
decodedMappings = (map) => {
return (map._decoded || (map._decoded = decode(map._encoded)));
};
originalPositionFor = (map, { line, column, bias }) => {
line--;
if (line < 0)
throw new Error(LINE_GTR_ZERO);
if (column < 0)
throw new Error(COL_GTR_EQ_ZERO);
const decoded = decodedMappings(map);
// It's common for parent source maps to have pointers to lines that have no
// mapping (like a "//# sourceMappingURL=") at the end of the child file.
if (line >= decoded.length)
return OMapping(null, null, null, null);
const segments = decoded[line];
const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
if (index === -1)
return OMapping(null, null, null, null);
const segment = segments[index];
if (segment.length === 1)
return OMapping(null, null, null, null);
const { names, resolvedSources } = map;
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
};
generatedPositionFor = (map, { source, line, column, bias }) => {
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
};
function generatedPosition(map, source, line, column, bias, all) {
line--;
if (line < 0)
throw new Error(LINE_GTR_ZERO);
if (column < 0)
throw new Error(COL_GTR_EQ_ZERO);
const { sources, resolvedSources } = map;
let sourceIndex = sources.indexOf(source);
if (sourceIndex === -1)
sourceIndex = resolvedSources.indexOf(source);
if (sourceIndex === -1)
return all ? [] : GMapping(null, null);
const generated = (map._bySources || (map._bySources = buildBySources(decodedMappings(map), (map._bySourceMemos = sources.map(memoizedState)))));
const segments = generated[sourceIndex][line];
if (segments == null)
return all ? [] : GMapping(null, null);
const memo = map._bySourceMemos[sourceIndex];
if (all)
return sliceGeneratedPositions(segments, memo, line, column, bias);
const index = traceSegmentInternal(segments, memo, line, column, bias);
if (index === -1)
return GMapping(null, null);
const segment = segments[index];
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
}
})();
/**
* Typescript doesn't allow friend access to private fields, so this just casts the map into a type
* with public access modifiers.
*/
function cast(map) {
return map;
}
/**
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
*/
function decodedMappings(map) {
var _a;
return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
}
/**
* A higher-level API to find the source/line/column associated with a generated line/column
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
* `source-map` library.
*/
function originalPositionFor(map, needle) {
let { line, column, bias } = needle;
line--;
if (line < 0)
throw new Error(LINE_GTR_ZERO);
if (column < 0)
throw new Error(COL_GTR_EQ_ZERO);
const decoded = decodedMappings(map);
// It's common for parent source maps to have pointers to lines that have no
// mapping (like a "//# sourceMappingURL=") at the end of the child file.
if (line >= decoded.length)
return OMapping(null, null, null, null);
const segments = decoded[line];
const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
if (index === -1)
return OMapping(null, null, null, null);
const segment = segments[index];
if (segment.length === 1)
return OMapping(null, null, null, null);
const { names, resolvedSources } = map;
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
}
/**
* Finds the generated line/column position of the provided source/line/column source position.
*/
function generatedPositionFor(map, needle) {
const { source, line, column, bias } = needle;
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
}
function OMapping(source, line, column, name) {

@@ -757,2 +740,28 @@ return { source, line, column, name };

}
function generatedPosition(map, source, line, column, bias, all) {
var _a;
line--;
if (line < 0)
throw new Error(LINE_GTR_ZERO);
if (column < 0)
throw new Error(COL_GTR_EQ_ZERO);
const { sources, resolvedSources } = map;
let sourceIndex = sources.indexOf(source);
if (sourceIndex === -1)
sourceIndex = resolvedSources.indexOf(source);
if (sourceIndex === -1)
return all ? [] : GMapping(null, null);
const generated = ((_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), (cast(map)._bySourceMemos = sources.map(memoizedState)))));
const segments = generated[sourceIndex][line];
if (segments == null)
return all ? [] : GMapping(null, null);
const memo = cast(map)._bySourceMemos[sourceIndex];
if (all)
return sliceGeneratedPositions(segments, memo, line, column, bias);
const index = traceSegmentInternal(segments, memo, line, column, bias);
if (index === -1)
return GMapping(null, null);
const segment = segments[index];
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
}

@@ -759,0 +768,0 @@ const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;

{
"name": "@vitest/utils",
"type": "module",
"version": "1.6.0",
"version": "2.0.0-beta.1",
"description": "Shared Vitest utility functions",

@@ -62,7 +62,7 @@ "license": "MIT",

"estree-walker": "^3.0.3",
"loupe": "^2.3.7",
"loupe": "^3.1.0",
"pretty-format": "^29.7.0"
},
"devDependencies": {
"@jridgewell/trace-mapping": "^0.3.22",
"@jridgewell/trace-mapping": "^0.3.25",
"@types/estree": "^1.0.5",

@@ -69,0 +69,0 @@ "tinyhighlight": "^0.3.2"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc