@vitest/utils 3.0.0 → 3.0.2

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.js CHANGED
@@ -1400,7 +1400,7 @@ function getDefaultOptions() {
1400
1400
  commonColor: c.dim,
1401
1401
  commonIndicator: " ",
1402
1402
  commonLineTrailingSpaceColor: noColor,
1403
- compareKeys: void 0,
1403
+ compareKeys: undefined,
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 : void 0;
1417
+ return compareKeys && typeof compareKeys === "function" ? compareKeys : undefined;
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 ? void 0 : options.truncateThreshold) ?? false;
1534
+ const truncate = (options == null ? undefined : options.truncateThreshold) ?? false;
1535
1535
  const truncateThreshold = Math.max(
1536
- Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0),
1536
+ Math.floor((options == null ? undefined : 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 === void 0) {
1568
+ if (value === undefined) {
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 ? void 0 : options.truncateThreshold) ?? false;
1607
+ const truncate = (options == null ? undefined : options.truncateThreshold) ?? false;
1608
1608
  const truncateThreshold = Math.max(
1609
- Math.floor((options == null ? void 0 : options.truncateThreshold) ?? 0),
1609
+ Math.floor((options == null ? undefined : 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 void 0;
1870
+ return undefined;
1871
1871
  }
1872
1872
  if (typeof a.getExpectedType !== "function") {
1873
- return void 0;
1873
+ return undefined;
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 void 0;
1898
+ return undefined;
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 === void 0 || difference === noDiffMessage) {
1935
+ if (difference === undefined || 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 === void 0 && err.expected !== void 0 && err.actual !== void 0) {
100
+ if (err.showDiff || err.showDiff === undefined && err.expected !== undefined && err.actual !== undefined) {
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 ? void 0 : e.message}
131
- Inner error message: ${err == null ? void 0 : err.message}`
130
+ `Failed to fully serialize error: ${e == null ? undefined : e.message}
131
+ Inner error message: ${err == null ? undefined : 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 === void 0) {
42
+ if (array === null || array === undefined) {
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 = void 0) {
127
+ function objectAttr(source, path, defaultValue = undefined) {
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 === void 0) {
132
+ if (result === undefined) {
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 === void 0) {
205
+ if (source === undefined) {
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] !== void 0 && match[1] !== "\\"
63
+ closed: match[1] !== undefined && 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] !== void 0
201
+ closed: match[2] !== undefined
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] !== void 0
302
+ closed: match[2] !== undefined
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] !== void 0
377
+ closed: match[1] !== undefined
378
378
  });
379
379
  continue;
380
380
  }
@@ -397,7 +397,7 @@ function requireJsTokens () {
397
397
  value: firstCodePoint
398
398
  });
399
399
  }
400
- return void 0;
400
+ return undefined;
401
401
  };
402
402
  return jsTokens_1;
403
403
  }
@@ -504,7 +504,7 @@ var colorize = (defs, type, value) => {
504
504
  }
505
505
  return highlighted;
506
506
  };
507
- function highlight$1(code, options = { jsx: !1, colors: {} }) {
507
+ function highlight$1(code, options = { jsx: false, colors: {} }) {
508
508
  return code && highlightTokens(options.colors || {}, code, options.jsx);
509
509
  }
510
510
 
@@ -22,7 +22,7 @@ function decodeInteger(reader, relative) {
22
22
  const shouldNegate = value & 1;
23
23
  value >>>= 1;
24
24
  if (shouldNegate) {
25
- value = -0x80000000 | -value;
25
+ value = -2147483648 | -value;
26
26
  }
27
27
  return relative + value;
28
28
  }
@@ -725,7 +725,6 @@ function normalizeWindowsPath(input = "") {
725
725
  return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
726
726
  }
727
727
  const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
728
- globalThis.process?.platform === "win32" ? ";" : ":";
729
728
  function cwd() {
730
729
  if (typeof process !== "undefined" && typeof process.cwd === "function") {
731
730
  return process.cwd().replace(/\\/g, "/");
@@ -857,7 +856,7 @@ function extractLocation(urlLike) {
857
856
  const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
858
857
  url = url.slice(isWindows ? 5 : 4);
859
858
  }
860
- return [url, parts[2] || void 0, parts[3] || void 0];
859
+ return [url, parts[2] || undefined, parts[3] || undefined];
861
860
  }
862
861
  function parseSingleFFOrSafariStack(raw) {
863
862
  let line = raw.trim();
@@ -875,7 +874,7 @@ function parseSingleFFOrSafariStack(raw) {
875
874
  }
876
875
  const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/;
877
876
  const matches = line.match(functionNameRegex);
878
- const functionName = matches && matches[1] ? matches[1] : void 0;
877
+ const functionName = matches && matches[1] ? matches[1] : undefined;
879
878
  const [url, lineNumber, columnNumber] = extractLocation(
880
879
  line.replace(functionNameRegex, "")
881
880
  );
@@ -911,7 +910,7 @@ function parseSingleV8Stack(raw) {
911
910
  location ? location[1] : sanitizedLine
912
911
  );
913
912
  let method = location && sanitizedLine || "";
914
- let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
913
+ let file = url && ["eval", "<anonymous>"].includes(url) ? undefined : url;
915
914
  if (!file || !lineNumber || !columnNumber) {
916
915
  return null;
917
916
  }
@@ -954,7 +953,7 @@ function parseStacktrace(stack, options = {}) {
954
953
  if (options.getFileName) {
955
954
  stack2.file = options.getFileName(stack2.file);
956
955
  }
957
- const map = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
956
+ const map = (_a = options.getSourceMap) == null ? undefined : _a.call(options, stack2.file);
958
957
  if (!map || typeof map !== "object" || !map.version) {
959
958
  return stack2;
960
959
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/utils",
3
3
  "type": "module",
4
- "version": "3.0.0",
4
+ "version": "3.0.2",
5
5
  "description": "Shared Vitest utility functions",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -62,7 +62,7 @@
62
62
  "dependencies": {
63
63
  "loupe": "^3.1.2",
64
64
  "tinyrainbow": "^2.0.0",
65
- "@vitest/pretty-format": "3.0.0"
65
+ "@vitest/pretty-format": "3.0.2"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@jridgewell/trace-mapping": "^0.3.25",