@vitest/utils 3.0.5 → 3.0.7

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.
@@ -1,4 +1,4 @@
1
- import { format as format$1, plugins } from '@vitest/pretty-format';
1
+ import { plugins, format as format$1 } from '@vitest/pretty-format';
2
2
  import * as loupe from 'loupe';
3
3
 
4
4
  const {
package/dist/diff.js CHANGED
@@ -1400,7 +1400,7 @@ function getDefaultOptions() {
1400
1400
  commonColor: c.dim,
1401
1401
  commonIndicator: " ",
1402
1402
  commonLineTrailingSpaceColor: noColor,
1403
- compareKeys: undefined,
1403
+ compareKeys: void 0,
1404
1404
  contextLines: DIFF_CONTEXT_DEFAULT,
1405
1405
  emptyFirstOrLastLinePlaceholder: "",
1406
1406
  expand: true,
@@ -1414,7 +1414,7 @@ function getDefaultOptions() {
1414
1414
  };
1415
1415
  }
1416
1416
  function getCompareKeys(compareKeys) {
1417
- return compareKeys && typeof compareKeys === "function" ? compareKeys : undefined;
1417
+ return compareKeys && typeof compareKeys === "function" ? compareKeys : void 0;
1418
1418
  }
1419
1419
  function getContextLines(contextLines) {
1420
1420
  return typeof contextLines === "number" && Number.isSafeInteger(contextLines) && contextLines >= 0 ? contextLines : DIFF_CONTEXT_DEFAULT;
@@ -1531,9 +1531,9 @@ function diffLinesUnified2(aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCo
1531
1531
  return printDiffLines(diffs, truncated, normalizeDiffOptions(options));
1532
1532
  }
1533
1533
  function diffLinesRaw(aLines, bLines, options) {
1534
- const truncate = (options == null ? undefined : options.truncateThreshold) ?? false;
1534
+ const truncate = (options == null ? void 0 : options.truncateThreshold) ?? false;
1535
1535
  const truncateThreshold = Math.max(
1536
- Math.floor((options == null ? undefined : options.truncateThreshold) ?? 0),
1536
+ Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0),
1537
1537
  0
1538
1538
  );
1539
1539
  const aLength = truncate ? Math.min(aLines.length, truncateThreshold) : aLines.length;
@@ -1565,7 +1565,7 @@ function diffLinesRaw(aLines, bLines, options) {
1565
1565
  }
1566
1566
 
1567
1567
  function getType(value) {
1568
- if (value === undefined) {
1568
+ if (value === void 0) {
1569
1569
  return "undefined";
1570
1570
  } else if (value === null) {
1571
1571
  return "null";
@@ -1604,9 +1604,9 @@ function getNewLineSymbol(string) {
1604
1604
  return string.includes("\r\n") ? "\r\n" : "\n";
1605
1605
  }
1606
1606
  function diffStrings(a, b, options) {
1607
- const truncate = (options == null ? undefined : options.truncateThreshold) ?? false;
1607
+ const truncate = (options == null ? void 0 : options.truncateThreshold) ?? false;
1608
1608
  const truncateThreshold = Math.max(
1609
- Math.floor((options == null ? undefined : options.truncateThreshold) ?? 0),
1609
+ Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0),
1610
1610
  0
1611
1611
  );
1612
1612
  let aLength = a.length;
@@ -1867,10 +1867,10 @@ function diff(a, b, options) {
1867
1867
  let omitDifference = false;
1868
1868
  if (aType === "object" && typeof a.asymmetricMatch === "function") {
1869
1869
  if (a.$$typeof !== Symbol.for("jest.asymmetricMatcher")) {
1870
- return undefined;
1870
+ return void 0;
1871
1871
  }
1872
1872
  if (typeof a.getExpectedType !== "function") {
1873
- return undefined;
1873
+ return void 0;
1874
1874
  }
1875
1875
  expectedType = a.getExpectedType();
1876
1876
  omitDifference = expectedType === "string";
@@ -1895,7 +1895,7 @@ ${bDisplay}`;
1895
1895
  ${bDiff}`;
1896
1896
  }
1897
1897
  if (omitDifference) {
1898
- return undefined;
1898
+ return void 0;
1899
1899
  }
1900
1900
  switch (aType) {
1901
1901
  case "string":
@@ -1932,7 +1932,7 @@ function compareObjects(a, b, options) {
1932
1932
  hasThrown = true;
1933
1933
  }
1934
1934
  const noDiffMessage = getCommonMessage(NO_DIFF_MESSAGE, options);
1935
- if (difference === undefined || difference === noDiffMessage) {
1935
+ if (difference === void 0 || difference === noDiffMessage) {
1936
1936
  const formatOptions = getFormatOptions(FALLBACK_FORMAT_OPTIONS, options);
1937
1937
  difference = getObjectsDifference(a, b, formatOptions, options);
1938
1938
  if (difference !== noDiffMessage && !hasThrown) {
package/dist/error.js CHANGED
@@ -97,7 +97,7 @@ function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
97
97
  if (err.name) {
98
98
  err.nameStr = String(err.name);
99
99
  }
100
- if (err.showDiff || err.showDiff === undefined && err.expected !== undefined && err.actual !== undefined) {
100
+ if (err.showDiff || err.showDiff === void 0 && err.expected !== void 0 && err.actual !== void 0) {
101
101
  err.diff = printDiffOrStringify(err.actual, err.expected, {
102
102
  ...diffOptions,
103
103
  ...err.diffOptions
@@ -127,8 +127,8 @@ function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
127
127
  } catch (e) {
128
128
  return serializeValue(
129
129
  new Error(
130
- `Failed to fully serialize error: ${e == null ? undefined : e.message}
131
- Inner error message: ${err == null ? undefined : err.message}`
130
+ `Failed to fully serialize error: ${e == null ? void 0 : e.message}
131
+ Inner error message: ${err == null ? void 0 : err.message}`
132
132
  )
133
133
  );
134
134
  }
package/dist/helpers.js CHANGED
@@ -39,7 +39,7 @@ function parseRegexp(input) {
39
39
  return new RegExp(m[2], m[3]);
40
40
  }
41
41
  function toArray(array) {
42
- if (array === null || array === undefined) {
42
+ if (array === null || array === void 0) {
43
43
  array = [];
44
44
  }
45
45
  if (Array.isArray(array)) {
@@ -124,12 +124,12 @@ function clone(val, seen, options = defaultCloneOptions) {
124
124
  }
125
125
  function noop() {
126
126
  }
127
- function objectAttr(source, path, defaultValue = undefined) {
127
+ function objectAttr(source, path, defaultValue = void 0) {
128
128
  const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
129
129
  let result = source;
130
130
  for (const p of paths) {
131
131
  result = new Object(result)[p];
132
- if (result === undefined) {
132
+ if (result === void 0) {
133
133
  return defaultValue;
134
134
  }
135
135
  }
@@ -202,7 +202,7 @@ function deepMerge(target, ...sources) {
202
202
  return target;
203
203
  }
204
204
  const source = sources.shift();
205
- if (source === undefined) {
205
+ if (source === void 0) {
206
206
  return target;
207
207
  }
208
208
  if (isMergeableObject(target) && isMergeableObject(source)) {
package/dist/index.js CHANGED
@@ -60,7 +60,7 @@ function requireJsTokens () {
60
60
  yield ({
61
61
  type: "RegularExpressionLiteral",
62
62
  value: match[0],
63
- closed: match[1] !== undefined && match[1] !== "\\"
63
+ closed: match[1] !== void 0 && match[1] !== "\\"
64
64
  });
65
65
  continue;
66
66
  }
@@ -198,7 +198,7 @@ function requireJsTokens () {
198
198
  yield ({
199
199
  type: "StringLiteral",
200
200
  value: match[0],
201
- closed: match[2] !== undefined
201
+ closed: match[2] !== void 0
202
202
  });
203
203
  continue;
204
204
  }
@@ -299,7 +299,7 @@ function requireJsTokens () {
299
299
  yield ({
300
300
  type: "JSXString",
301
301
  value: match[0],
302
- closed: match[2] !== undefined
302
+ closed: match[2] !== void 0
303
303
  });
304
304
  continue;
305
305
  }
@@ -374,7 +374,7 @@ function requireJsTokens () {
374
374
  yield ({
375
375
  type: "MultiLineComment",
376
376
  value: match[0],
377
- closed: match[1] !== undefined
377
+ closed: match[1] !== void 0
378
378
  });
379
379
  continue;
380
380
  }
@@ -397,7 +397,7 @@ function requireJsTokens () {
397
397
  value: firstCodePoint
398
398
  });
399
399
  }
400
- return undefined;
400
+ return void 0;
401
401
  };
402
402
  return jsTokens_1;
403
403
  }
@@ -1,4 +1,4 @@
1
- import { notNullish, isPrimitive } from './helpers.js';
1
+ import { isPrimitive, notNullish } from './helpers.js';
2
2
 
3
3
  const comma = ','.charCodeAt(0);
4
4
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -663,33 +663,6 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
663
663
  return -1;
664
664
  return index;
665
665
  }
666
- function sliceGeneratedPositions(segments, memo, line, column, bias) {
667
- let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
668
- // We ignored the bias when tracing the segment so that we're guarnateed to find the first (in
669
- // insertion order) segment that matched. Even if we did respect the bias when tracing, we would
670
- // still need to call `lowerBound()` to find the first segment, which is slower than just looking
671
- // for the GREATEST_LOWER_BOUND to begin with. The only difference that matters for us is when the
672
- // binary search didn't match, in which case GREATEST_LOWER_BOUND just needs to increment to
673
- // match LEAST_UPPER_BOUND.
674
- if (!found && bias === LEAST_UPPER_BOUND)
675
- min++;
676
- if (min === -1 || min === segments.length)
677
- return [];
678
- // We may have found the segment that started at an earlier column. If this is the case, then we
679
- // need to slice all generated segments that match _that_ column, because all such segments span
680
- // to our desired column.
681
- const matchedColumn = found ? column : segments[min][COLUMN];
682
- // The binary search is not guaranteed to find the lower bound when a match wasn't found.
683
- if (!found)
684
- min = lowerBound(segments, matchedColumn, min);
685
- const max = upperBound(segments, matchedColumn, min);
686
- const result = [];
687
- for (; min <= max; min++) {
688
- const segment = segments[min];
689
- result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
690
- }
691
- return result;
692
- }
693
666
  function generatedPosition(map, source, line, column, bias, all) {
694
667
  var _a;
695
668
  line--;
@@ -708,8 +681,6 @@ function generatedPosition(map, source, line, column, bias, all) {
708
681
  if (segments == null)
709
682
  return all ? [] : GMapping(null, null);
710
683
  const memo = cast(map)._bySourceMemos[sourceIndex];
711
- if (all)
712
- return sliceGeneratedPositions(segments, memo, line, column, bias);
713
684
  const index = traceSegmentInternal(segments, memo, line, column, bias);
714
685
  if (index === -1)
715
686
  return GMapping(null, null);
@@ -856,7 +827,7 @@ function extractLocation(urlLike) {
856
827
  const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
857
828
  url = url.slice(isWindows ? 5 : 4);
858
829
  }
859
- return [url, parts[2] || undefined, parts[3] || undefined];
830
+ return [url, parts[2] || void 0, parts[3] || void 0];
860
831
  }
861
832
  function parseSingleFFOrSafariStack(raw) {
862
833
  let line = raw.trim();
@@ -874,7 +845,7 @@ function parseSingleFFOrSafariStack(raw) {
874
845
  }
875
846
  const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
876
847
  const matches = line.match(functionNameRegex);
877
- const functionName = matches && matches[1] ? matches[1] : undefined;
848
+ const functionName = matches && matches[1] ? matches[1] : void 0;
878
849
  const [url, lineNumber, columnNumber] = extractLocation(
879
850
  line.replace(functionNameRegex, "")
880
851
  );
@@ -910,7 +881,7 @@ function parseSingleV8Stack(raw) {
910
881
  location ? location[1] : sanitizedLine
911
882
  );
912
883
  let method = location && sanitizedLine || "";
913
- let file = url && ["eval", "<anonymous>"].includes(url) ? undefined : url;
884
+ let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
914
885
  if (!file || !lineNumber || !columnNumber) {
915
886
  return null;
916
887
  }
@@ -953,7 +924,7 @@ function parseStacktrace(stack, options = {}) {
953
924
  if (options.getFileName) {
954
925
  stack2.file = options.getFileName(stack2.file);
955
926
  }
956
- const map = (_a = options.getSourceMap) == null ? undefined : _a.call(options, stack2.file);
927
+ const map = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
957
928
  if (!map || typeof map !== "object" || !map.version) {
958
929
  return stack2;
959
930
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/utils",
3
3
  "type": "module",
4
- "version": "3.0.5",
4
+ "version": "3.0.7",
5
5
  "description": "Shared Vitest utility functions",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -60,9 +60,9 @@
60
60
  "dist"
61
61
  ],
62
62
  "dependencies": {
63
- "loupe": "^3.1.2",
63
+ "loupe": "^3.1.3",
64
64
  "tinyrainbow": "^2.0.0",
65
- "@vitest/pretty-format": "3.0.5"
65
+ "@vitest/pretty-format": "3.0.7"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@jridgewell/trace-mapping": "^0.3.25",