Socket
Socket
Sign inDemoInstall

@vitest/utils

Package Overview
Dependencies
Maintainers
3
Versions
95
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 0.32.2 to 0.32.3

7

./dist/index.js
import { notNullish, isPrimitive } from './helpers.js';
export { assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isObject, noop, objectAttr, parseRegexp, slash, toArray } from './helpers.js';
export { f as format, l as loupeInspect, o as objDisplay, s as stringify, u as utilInspect } from './chunk-display.js';
export { f as format, i as inspect, o as objDisplay, s as stringify } from './chunk-display.js';
import { S as SAFE_TIMERS_SYMBOL } from './chunk-colors.js';
export { a as SAFE_COLORS_SYMBOL, c as createColors, b as getColors, g as getDefaultColors, s as setupColors } from './chunk-colors.js';
import 'pretty-format';
import 'util';
import 'loupe';

@@ -222,4 +221,4 @@

file,
line: parseInt(lineNumber),
column: parseInt(columnNumber)
line: Number.parseInt(lineNumber),
column: Number.parseInt(columnNumber)
};

@@ -226,0 +225,0 @@ }

import { format as format$1, plugins } from 'pretty-format';
import util from 'util';
import loupeImport from 'loupe';
import { inspect as inspect$1 } from 'loupe';

@@ -45,18 +44,83 @@ const {

const loupe = typeof loupeImport.default === "function" ? loupeImport.default : loupeImport;
const formatRegExp = /%[sdjifoOcj%]/g;
function format(...args) {
return util.format(...args);
if (typeof args[0] !== "string") {
const objects = [];
for (let i2 = 0; i2 < args.length; i2++)
objects.push(inspect(args[i2], { depth: 0, colors: false, compact: 3 }));
return objects.join(" ");
}
const len = args.length;
let i = 1;
const template = args[0];
let str = String(template).replace(formatRegExp, (x) => {
if (x === "%%")
return "%";
if (i >= len)
return x;
switch (x) {
case "%s": {
const value = args[i++];
if (typeof value === "bigint")
return `${value.toString()}n`;
if (typeof value === "number" && value === 0 && 1 / value < 0)
return "-0";
if (typeof value === "object" && value !== null)
return inspect(value, { depth: 0, colors: false, compact: 3 });
return String(value);
}
case "%d": {
const value = args[i++];
if (typeof value === "bigint")
return `${value.toString()}n`;
return Number(value).toString();
}
case "%i": {
const value = args[i++];
if (typeof value === "bigint")
return `${value.toString()}n`;
return Number.parseInt(String(value)).toString();
}
case "%f":
return Number.parseFloat(String(args[i++])).toString();
case "%o":
return inspect(args[i++], { showHidden: true, showProxy: true });
case "%O":
return inspect(args[i++]);
case "%c": {
i++;
return "";
}
case "%j":
try {
return JSON.stringify(args[i++]);
} catch (err) {
const m = err.message;
if (
// chromium
m.includes("circular structure") || m.includes("cyclic structures") || m.includes("cyclic object")
)
return "[Circular]";
throw err;
}
default:
return x;
}
});
for (let x = args[i]; i < len; x = args[++i]) {
if (x === null || typeof x !== "object")
str += ` ${x}`;
else
str += ` ${inspect(x)}`;
}
return str;
}
function utilInspect(item, options) {
return util.inspect(item, options);
function inspect(obj, options = {}) {
if (options.truncate === 0)
options.truncate = Number.POSITIVE_INFINITY;
return inspect$1(obj, options);
}
function loupeInspect(obj, options = {}) {
return loupe(obj, {
depth: 2,
truncate: options.truncateThreshold === 0 ? Infinity : options.truncateThreshold ?? 40
});
}
function objDisplay(obj, options = {}) {
const truncateThreshold = options.truncateThreshold ?? 40;
const str = loupeInspect(obj, options);
const truncateThreshold = options.truncate ?? 40;
const str = inspect(obj, options);
const type = Object.prototype.toString.call(obj);

@@ -80,2 +144,2 @@ if (truncateThreshold && str.length >= truncateThreshold) {

export { format as f, loupeInspect as l, objDisplay as o, stringify as s, utilInspect as u };
export { format as f, inspect as i, objDisplay as o, stringify as s };

@@ -112,4 +112,10 @@ import { CompareKeys } from 'pretty-format';

/**
* @param a Expected value
* @param b Received value
* @param options Diff options
* @returns
*/
declare function diff(a: any, b: any, options?: DiffOptions): string | null;
export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, DiffOptions, DiffOptionsColor, diff, diffLinesRaw, diffLinesUnified, diffLinesUnified2, diffStringsRaw, diffStringsUnified };

@@ -44,2 +44,4 @@ import { format, plugins } from 'pretty-format';

class Diff {
0;
1;
constructor(op, text) {

@@ -730,3 +732,4 @@ this[0] = op;

};
diff$1.default.default(aLength, bLength, isCommon, foundSubsequence);
const diffSequences = diff$1.default.default || diff$1.default;
diffSequences(aLength, bLength, isCommon, foundSubsequence);
for (; aIndex !== aLength; aIndex += 1)

@@ -753,3 +756,4 @@ diffs.push(new Diff(DIFF_DELETE, aLines[aIndex]));

};
diff$1.default.default(a.length, b.length, isCommon, foundSubsequence);
const diffSequences = diff$1.default.default || diff$1.default;
diffSequences(a.length, b.length, isCommon, foundSubsequence);
if (aIndex !== a.length)

@@ -769,2 +773,8 @@ diffs.push(new Diff(DIFF_DELETE, a.slice(aIndex)));

class ChangeBuffer {
op;
line;
// incomplete line
lines;
// complete lines
changeColor;
constructor(op, changeColor) {

@@ -823,2 +833,5 @@ this.op = op;

class CommonBuffer {
deleteBuffer;
insertBuffer;
lines;
constructor(deleteBuffer, insertBuffer) {

@@ -825,0 +838,0 @@ this.deleteBuffer = deleteBuffer;

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

import './chunk-colors.js';
import 'util';
import 'loupe';

@@ -85,3 +84,3 @@

if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0)
err.diff = diff(err.actual, err.expected);
err.diff = diff(err.expected, err.actual);
if (typeof err.expected !== "string")

@@ -88,0 +87,0 @@ err.expected = stringify(err.expected, 10);

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

import { PrettyFormatOptions } from 'pretty-format';
import util from 'util';

@@ -26,7 +25,18 @@ declare function stringify(object: unknown, maxDepth?: number, { maxLength, ...options }?: PrettyFormatOptions & {

interface LoupeOptions {
truncateThreshold?: number;
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;
}
declare function format(...args: any[]): string;
declare function utilInspect(item: unknown, options?: util.InspectOptions): string;
declare function loupeInspect(obj: unknown, options?: LoupeOptions): string;
declare function format(...args: unknown[]): string;
declare function inspect(obj: unknown, options?: LoupeOptions): any;
declare function objDisplay(obj: unknown, options?: LoupeOptions): string;

@@ -98,2 +108,2 @@

export { ErrorWithDiff, ParsedStack, SAFE_COLORS_SYMBOL, SAFE_TIMERS_SYMBOL, createColors, createSimpleStackTrace, format, getColors, getDefaultColors, getSafeTimers, lineSplitRE, loupeInspect, objDisplay, offsetToLineNumber, parseErrorStacktrace, parseSingleStack, parseStacktrace, positionToOffset, setSafeTimers, setupColors, shuffle, stringify, utilInspect };
export { ErrorWithDiff, ParsedStack, SAFE_COLORS_SYMBOL, SAFE_TIMERS_SYMBOL, createColors, createSimpleStackTrace, format, getColors, getDefaultColors, getSafeTimers, inspect, lineSplitRE, objDisplay, offsetToLineNumber, parseErrorStacktrace, parseSingleStack, parseStacktrace, positionToOffset, setSafeTimers, setupColors, shuffle, stringify };
import { notNullish, isPrimitive } from './helpers.js';
export { assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isObject, noop, objectAttr, parseRegexp, slash, toArray } from './helpers.js';
export { f as format, l as loupeInspect, o as objDisplay, s as stringify, u as utilInspect } from './chunk-display.js';
export { f as format, i as inspect, o as objDisplay, s as stringify } from './chunk-display.js';
import { S as SAFE_TIMERS_SYMBOL } from './chunk-colors.js';
export { a as SAFE_COLORS_SYMBOL, c as createColors, b as getColors, g as getDefaultColors, s as setupColors } from './chunk-colors.js';
import 'pretty-format';
import 'util';
import 'loupe';

@@ -222,4 +221,4 @@

file,
line: parseInt(lineNumber),
column: parseInt(columnNumber)
line: Number.parseInt(lineNumber),
column: Number.parseInt(columnNumber)
};

@@ -226,0 +225,0 @@ }

{
"name": "@vitest/utils",
"type": "module",
"version": "0.32.2",
"version": "0.32.3",
"description": "Shared Vitest utility functions",

@@ -47,3 +47,3 @@ "license": "MIT",

"loupe": "^2.3.6",
"pretty-format": "^27.5.1"
"pretty-format": "^29.5.0"
},

@@ -50,0 +50,0 @@ "scripts": {

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