@vitest/utils 1.0.0-beta.1 → 1.0.0-beta.3

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/diff.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as DiffOptions } from './types-f5c02aaf.js';
2
- export { a as DiffOptionsColor } from './types-f5c02aaf.js';
1
+ import { D as DiffOptions } from './types-39717483.js';
2
+ export { a as DiffOptionsColor } from './types-39717483.js';
3
3
  import 'pretty-format';
4
4
 
5
5
  /**
package/dist/error.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { D as DiffOptions } from './types-f5c02aaf.js';
1
+ import { D as DiffOptions } from './types-39717483.js';
2
2
  import 'pretty-format';
3
3
 
4
4
  declare function serializeError(val: any, seen?: WeakMap<object, any>): any;
package/dist/helpers.d.ts CHANGED
@@ -32,4 +32,4 @@ declare function createDefer<T>(): DeferPromise<T>;
32
32
  */
33
33
  declare function getCallLastIndex(code: string): number | null;
34
34
 
35
- export { DeferPromise, assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray };
35
+ export { type DeferPromise, assertTypes, clone, createDefer, deepClone, getCallLastIndex, getOwnProperties, getType, isObject, isPrimitive, noop, notNullish, objectAttr, parseRegexp, slash, toArray };
package/dist/helpers.js CHANGED
@@ -62,7 +62,7 @@ function clone(val, seen, options = defaultCloneOptions) {
62
62
  out = Array(k = val.length);
63
63
  seen.set(val, out);
64
64
  while (k--)
65
- out[k] = clone(val[k], seen);
65
+ out[k] = clone(val[k], seen, options);
66
66
  return out;
67
67
  }
68
68
  if (Object.prototype.toString.call(val) === "[object Object]") {
@@ -73,7 +73,7 @@ function clone(val, seen, options = defaultCloneOptions) {
73
73
  const descriptor = Object.getOwnPropertyDescriptor(val, k2);
74
74
  if (!descriptor)
75
75
  continue;
76
- const cloned = clone(val[k2], seen);
76
+ const cloned = clone(val[k2], seen, options);
77
77
  if ("get" in descriptor) {
78
78
  Object.defineProperty(out, k2, {
79
79
  ...descriptor,
@@ -100,6 +100,7 @@ declare class TraceMap implements SourceMap {
100
100
  interface StackTraceParserOptions {
101
101
  ignoreStackEntries?: (RegExp | string)[];
102
102
  getSourceMap?: (file: string) => unknown;
103
+ frameFilter?: (error: Error, frame: ParsedStack) => boolean | void;
103
104
  }
104
105
  declare function parseSingleFFOrSafariStack(raw: string): ParsedStack | null;
105
106
  declare function parseSingleStack(raw: string): ParsedStack | null;
@@ -107,4 +108,4 @@ declare function parseSingleV8Stack(raw: string): ParsedStack | null;
107
108
  declare function parseStacktrace(stack: string, options?: StackTraceParserOptions): ParsedStack[];
108
109
  declare function parseErrorStacktrace(e: ErrorWithDiff, options?: StackTraceParserOptions): ParsedStack[];
109
110
 
110
- export { SourceMapInput, StackTraceParserOptions, TraceMap, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace };
111
+ export { type SourceMapInput, type StackTraceParserOptions, TraceMap, generatedPositionFor, originalPositionFor, parseErrorStacktrace, parseSingleFFOrSafariStack, parseSingleStack, parseSingleV8Stack, parseStacktrace };
@@ -868,7 +868,9 @@ function parseErrorStacktrace(e, options = {}) {
868
868
  if (e.stacks)
869
869
  return e.stacks;
870
870
  const stackStr = e.stack || e.stackStr || "";
871
- const stackFrames = parseStacktrace(stackStr, options);
871
+ let stackFrames = parseStacktrace(stackStr, options);
872
+ if (options.frameFilter)
873
+ stackFrames = stackFrames.filter((f) => options.frameFilter(e, f) !== false);
872
874
  e.stacks = stackFrames;
873
875
  return stackFrames;
874
876
  }
@@ -29,4 +29,4 @@ interface DiffOptions {
29
29
  compareKeys?: CompareKeys;
30
30
  }
31
31
 
32
- export { DiffOptions as D, DiffOptionsColor as a };
32
+ export type { DiffOptions as D, DiffOptionsColor as a };
package/dist/types.d.ts CHANGED
@@ -35,4 +35,4 @@ interface ErrorWithDiff extends Error {
35
35
  diff?: string;
36
36
  }
37
37
 
38
- export { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, ErrorWithDiff, MergeInsertions, MutableArray, Nullable, ParsedStack };
38
+ export type { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, ErrorWithDiff, MergeInsertions, MutableArray, Nullable, ParsedStack };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/utils",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.1",
4
+ "version": "1.0.0-beta.3",
5
5
  "description": "Shared Vitest utility functions",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -47,7 +47,7 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "diff-sequences": "^29.4.3",
50
- "loupe": "^2.3.6",
50
+ "loupe": "^2.3.7",
51
51
  "pretty-format": "^29.5.0"
52
52
  },
53
53
  "devDependencies": {