@vitest/utils 0.28.4 → 0.28.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -1
- package/dist/index.js +14 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -27,4 +27,15 @@ declare const SAFE_COLORS_SYMBOL: unique symbol;
|
|
27
27
|
declare function getColors(): typeof p;
|
28
28
|
declare function setColors(colors: typeof p): void;
|
29
29
|
|
30
|
-
|
30
|
+
interface ErrorOptions {
|
31
|
+
message?: string;
|
32
|
+
stackTraceLimit?: number;
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* Get original stacktrace without source map support the most performant way.
|
36
|
+
* - Create only 1 stack frame.
|
37
|
+
* - Rewrite prepareStackTrace to bypass "support-stack-trace" (usually takes ~250ms).
|
38
|
+
*/
|
39
|
+
declare function createSimpleStackTrace(options?: ErrorOptions): string;
|
40
|
+
|
41
|
+
export { SAFE_COLORS_SYMBOL, SAFE_TIMERS_SYMBOL, createSimpleStackTrace, format, getColors, getSafeTimers, inspect, objDisplay, setColors, setSafeTimers, shuffle, stringify };
|
package/dist/index.js
CHANGED
@@ -161,4 +161,17 @@ function setColors(colors2) {
|
|
161
161
|
globalThis[SAFE_COLORS_SYMBOL] = colors2;
|
162
162
|
}
|
163
163
|
|
164
|
-
|
164
|
+
function createSimpleStackTrace(options) {
|
165
|
+
const { message = "error", stackTraceLimit = 1 } = options || {};
|
166
|
+
const limit = Error.stackTraceLimit;
|
167
|
+
const prepareStackTrace = Error.prepareStackTrace;
|
168
|
+
Error.stackTraceLimit = stackTraceLimit;
|
169
|
+
Error.prepareStackTrace = (e) => e.stack;
|
170
|
+
const err = new Error(message);
|
171
|
+
const stackTrace = err.stack || "";
|
172
|
+
Error.prepareStackTrace = prepareStackTrace;
|
173
|
+
Error.stackTraceLimit = limit;
|
174
|
+
return stackTrace;
|
175
|
+
}
|
176
|
+
|
177
|
+
export { SAFE_COLORS_SYMBOL, SAFE_TIMERS_SYMBOL, createSimpleStackTrace, format, getColors, getSafeTimers, inspect, objDisplay, setColors, setSafeTimers, shuffle, stringify };
|