@vitest/utils
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -0,3 +1,3 @@ | ||
import * as loupe from 'loupe'; | ||
import { format as format$1, plugins } from '@vitest/pretty-format'; | ||
import * as loupe from 'loupe'; | ||
@@ -43,3 +43,2 @@ const { | ||
} | ||
const formatRegExp = /%[sdjifoOc%]/g; | ||
@@ -46,0 +45,0 @@ function format(...args) { |
@@ -6,2 +6,12 @@ import { Nullable, Arrayable } from './types.js'; | ||
} | ||
interface ErrorOptions { | ||
message?: string; | ||
stackTraceLimit?: number; | ||
} | ||
/** | ||
* Get original stacktrace without source map support the most performant way. | ||
* - Create only 1 stack frame. | ||
* - Rewrite prepareStackTrace to bypass "support-stack-trace" (usually takes ~250ms). | ||
*/ | ||
declare function createSimpleStackTrace(options?: ErrorOptions): string; | ||
declare function notNullish<T>(v: T | null | undefined): v is NonNullable<T>; | ||
@@ -37,2 +47,2 @@ declare function assertTypes(value: unknown, name: string, types: string[]): void; | ||
export { type DeferPromise, assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray }; | ||
export { type DeferPromise, assertTypes, clone, createDefer, createSimpleStackTrace, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray }; |
@@ -0,1 +1,13 @@ | ||
function createSimpleStackTrace(options) { | ||
const { message = "$$stack trace error", stackTraceLimit = 1 } = options || {}; | ||
const limit = Error.stackTraceLimit; | ||
const prepareStackTrace = Error.prepareStackTrace; | ||
Error.stackTraceLimit = stackTraceLimit; | ||
Error.prepareStackTrace = (e) => e.stack; | ||
const err = new Error(message); | ||
const stackTrace = err.stack || ""; | ||
Error.prepareStackTrace = prepareStackTrace; | ||
Error.stackTraceLimit = limit; | ||
return stackTrace; | ||
} | ||
function notNullish(v) { | ||
@@ -180,2 +192,2 @@ return v != null; | ||
export { assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray }; | ||
export { assertTypes, clone, createDefer, createSimpleStackTrace, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray }; |
@@ -1,19 +0,16 @@ | ||
export { DeferPromise, assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray } from './helpers.js'; | ||
export { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, ErrorWithDiff, MergeInsertions, MutableArray, Nullable, ParsedStack } from './types.js'; | ||
export { DeferPromise, assertTypes, clone, createDefer, createSimpleStackTrace, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray } from './helpers.js'; | ||
import { PrettyFormatOptions } from '@vitest/pretty-format'; | ||
import { Colors } from 'tinyrainbow'; | ||
export { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, ErrorWithDiff, MergeInsertions, MutableArray, Nullable, ParsedStack } from './types.js'; | ||
declare function stringify(object: unknown, maxDepth?: number, { maxLength, ...options }?: PrettyFormatOptions & { | ||
maxLength?: number; | ||
}): string; | ||
declare function getSafeTimers(): { | ||
nextTick: any; | ||
setTimeout: any; | ||
setInterval: any; | ||
clearInterval: any; | ||
clearTimeout: any; | ||
setImmediate: any; | ||
clearImmediate: any; | ||
}; | ||
interface SafeTimers { | ||
nextTick: (cb: () => void) => void; | ||
setTimeout: typeof setTimeout; | ||
setInterval: typeof setInterval; | ||
clearInterval: typeof clearInterval; | ||
clearTimeout: typeof clearTimeout; | ||
setImmediate: typeof setImmediate; | ||
clearImmediate: typeof clearImmediate; | ||
} | ||
declare function getSafeTimers(): SafeTimers; | ||
declare function setSafeTimers(): void; | ||
@@ -38,2 +35,5 @@ | ||
type LoupeOptions = Partial<Options>; | ||
declare function stringify(object: unknown, maxDepth?: number, { maxLength, ...options }?: PrettyFormatOptions & { | ||
maxLength?: number; | ||
}): string; | ||
declare function format(...args: unknown[]): string; | ||
@@ -43,16 +43,2 @@ declare function inspect(obj: unknown, options?: LoupeOptions): string; | ||
declare const SAFE_TIMERS_SYMBOL: unique symbol; | ||
declare const SAFE_COLORS_SYMBOL: unique symbol; | ||
interface ErrorOptions { | ||
message?: string; | ||
stackTraceLimit?: number; | ||
} | ||
/** | ||
* Get original stacktrace without source map support the most performant way. | ||
* - Create only 1 stack frame. | ||
* - Rewrite prepareStackTrace to bypass "support-stack-trace" (usually takes ~250ms). | ||
*/ | ||
declare function createSimpleStackTrace(options?: ErrorOptions): string; | ||
declare const lineSplitRE: RegExp; | ||
@@ -68,2 +54,2 @@ declare function positionToOffset(source: string, lineNumber: number, columnNumber: number): number; | ||
export { SAFE_COLORS_SYMBOL, SAFE_TIMERS_SYMBOL, createSimpleStackTrace, format, getSafeTimers, highlight, inspect, lineSplitRE, objDisplay, offsetToLineNumber, positionToOffset, setSafeTimers, shuffle, stringify }; | ||
export { type SafeTimers, format, getSafeTimers, highlight, inspect, lineSplitRE, objDisplay, offsetToLineNumber, positionToOffset, setSafeTimers, shuffle, stringify }; |
@@ -1,10 +0,8 @@ | ||
export { assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray } from './helpers.js'; | ||
export { assertTypes, clone, createDefer, createSimpleStackTrace, deepClone, getCallLastIndex, getOwnProperties, getType, isNegativeNaN, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray } from './helpers.js'; | ||
export { f as format, i as inspect, o as objDisplay, s as stringify } from './chunk-display.js'; | ||
import c from 'tinyrainbow'; | ||
import 'loupe'; | ||
import '@vitest/pretty-format'; | ||
import 'loupe'; | ||
const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS"); | ||
const SAFE_COLORS_SYMBOL = Symbol("vitest:SAFE_COLORS"); | ||
function getSafeTimers() { | ||
@@ -71,15 +69,2 @@ const { | ||
function createSimpleStackTrace(options) { | ||
const { message = "$$stack trace error", stackTraceLimit = 1 } = options || {}; | ||
const limit = Error.stackTraceLimit; | ||
const prepareStackTrace = Error.prepareStackTrace; | ||
Error.stackTraceLimit = stackTraceLimit; | ||
Error.prepareStackTrace = (e) => e.stack; | ||
const err = new Error(message); | ||
const stackTrace = err.stack || ""; | ||
Error.prepareStackTrace = prepareStackTrace; | ||
Error.stackTraceLimit = limit; | ||
return stackTrace; | ||
} | ||
const lineSplitRE = /\r?\n/; | ||
@@ -647,2 +632,2 @@ function positionToOffset(source, lineNumber, columnNumber) { | ||
export { SAFE_COLORS_SYMBOL, SAFE_TIMERS_SYMBOL, createSimpleStackTrace, getSafeTimers, highlight, lineSplitRE, offsetToLineNumber, positionToOffset, setSafeTimers, shuffle }; | ||
export { getSafeTimers, highlight, lineSplitRE, offsetToLineNumber, positionToOffset, setSafeTimers, shuffle }; |
{ | ||
"name": "@vitest/utils", | ||
"type": "module", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "Shared Vitest utility functions", | ||
@@ -66,3 +66,3 @@ "license": "MIT", | ||
"tinyrainbow": "^1.2.0", | ||
"@vitest/pretty-format": "2.0.3" | ||
"@vitest/pretty-format": "2.0.4" | ||
}, | ||
@@ -69,0 +69,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
179304
5151
+ Added@vitest/pretty-format@2.0.4(transitive)
- Removed@vitest/pretty-format@2.0.3(transitive)
Updated@vitest/pretty-format@2.0.4