@vitest/utils 1.0.0-beta.3 → 1.0.0-beta.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/diff.d.ts +7 -7
- package/dist/diff.js +7 -31
- package/dist/error.d.ts +3 -3
- package/dist/error.js +1 -1
- package/dist/source-map.js +1 -1
- package/package.json +11 -11
- /package/dist/{types-39717483.d.ts → types-widbdqe5.d.ts} +0 -0
package/dist/diff.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { D as DiffOptions } from './types-
|
2
|
-
export { a as DiffOptionsColor } from './types-
|
1
|
+
import { D as DiffOptions } from './types-widbdqe5.js';
|
2
|
+
export { a as DiffOptionsColor } from './types-widbdqe5.js';
|
3
3
|
import 'pretty-format';
|
4
4
|
|
5
5
|
/**
|
@@ -77,16 +77,16 @@ declare function diffStringsRaw(a: string, b: string, cleanup: boolean): Array<D
|
|
77
77
|
|
78
78
|
/**
|
79
79
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
80
|
-
*
|
81
|
-
* This source code is licensed under the MIT license found in the
|
82
|
-
* LICENSE file in the root directory of this source tree.
|
83
|
-
*/
|
80
|
+
*
|
81
|
+
* This source code is licensed under the MIT license found in the
|
82
|
+
* LICENSE file in the root directory of this source tree.
|
83
|
+
*/
|
84
84
|
|
85
85
|
/**
|
86
86
|
* @param a Expected value
|
87
87
|
* @param b Received value
|
88
88
|
* @param options Diff options
|
89
|
-
* @returns
|
89
|
+
* @returns {string | null} a string diff
|
90
90
|
*/
|
91
91
|
declare function diff(a: any, b: any, options?: DiffOptions): string | null;
|
92
92
|
|
package/dist/diff.js
CHANGED
@@ -133,15 +133,8 @@ const diff_cleanupSemantic = function(diffs) {
|
|
133
133
|
length_insertions2 += diffs[pointer][1].length;
|
134
134
|
else
|
135
135
|
length_deletions2 += diffs[pointer][1].length;
|
136
|
-
if (lastEquality && lastEquality.length <= Math.max(length_insertions1, length_deletions1) && lastEquality.length <= Math.max(
|
137
|
-
|
138
|
-
length_deletions2
|
139
|
-
)) {
|
140
|
-
diffs.splice(
|
141
|
-
equalities[equalitiesLength - 1],
|
142
|
-
0,
|
143
|
-
new Diff(DIFF_DELETE, lastEquality)
|
144
|
-
);
|
136
|
+
if (lastEquality && lastEquality.length <= Math.max(length_insertions1, length_deletions1) && lastEquality.length <= Math.max(length_insertions2, length_deletions2)) {
|
137
|
+
diffs.splice(equalities[equalitiesLength - 1], 0, new Diff(DIFF_DELETE, lastEquality));
|
145
138
|
diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT;
|
146
139
|
equalitiesLength--;
|
147
140
|
equalitiesLength--;
|
@@ -168,20 +161,14 @@ const diff_cleanupSemantic = function(diffs) {
|
|
168
161
|
const overlap_length2 = diff_commonOverlap_(insertion, deletion);
|
169
162
|
if (overlap_length1 >= overlap_length2) {
|
170
163
|
if (overlap_length1 >= deletion.length / 2 || overlap_length1 >= insertion.length / 2) {
|
171
|
-
diffs.splice(pointer, 0, new Diff(
|
172
|
-
DIFF_EQUAL,
|
173
|
-
insertion.substring(0, overlap_length1)
|
174
|
-
));
|
164
|
+
diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, insertion.substring(0, overlap_length1)));
|
175
165
|
diffs[pointer - 1][1] = deletion.substring(0, deletion.length - overlap_length1);
|
176
166
|
diffs[pointer + 1][1] = insertion.substring(overlap_length1);
|
177
167
|
pointer++;
|
178
168
|
}
|
179
169
|
} else {
|
180
170
|
if (overlap_length2 >= deletion.length / 2 || overlap_length2 >= insertion.length / 2) {
|
181
|
-
diffs.splice(pointer, 0, new Diff(
|
182
|
-
DIFF_EQUAL,
|
183
|
-
deletion.substring(0, overlap_length2)
|
184
|
-
));
|
171
|
+
diffs.splice(pointer, 0, new Diff(DIFF_EQUAL, deletion.substring(0, overlap_length2)));
|
185
172
|
diffs[pointer - 1][0] = DIFF_INSERT;
|
186
173
|
diffs[pointer - 1][1] = insertion.substring(0, insertion.length - overlap_length2);
|
187
174
|
diffs[pointer + 1][0] = DIFF_DELETE;
|
@@ -303,10 +290,7 @@ function diff_cleanupMerge(diffs) {
|
|
303
290
|
if (pointer - count_delete - count_insert > 0 && diffs[pointer - count_delete - count_insert - 1][0] === DIFF_EQUAL) {
|
304
291
|
diffs[pointer - count_delete - count_insert - 1][1] += text_insert.substring(0, commonlength);
|
305
292
|
} else {
|
306
|
-
diffs.splice(0, 0, new Diff(
|
307
|
-
DIFF_EQUAL,
|
308
|
-
text_insert.substring(0, commonlength)
|
309
|
-
));
|
293
|
+
diffs.splice(0, 0, new Diff(DIFF_EQUAL, text_insert.substring(0, commonlength)));
|
310
294
|
pointer++;
|
311
295
|
}
|
312
296
|
text_insert = text_insert.substring(commonlength);
|
@@ -322,19 +306,11 @@ function diff_cleanupMerge(diffs) {
|
|
322
306
|
pointer -= count_delete + count_insert;
|
323
307
|
diffs.splice(pointer, count_delete + count_insert);
|
324
308
|
if (text_delete.length) {
|
325
|
-
diffs.splice(
|
326
|
-
pointer,
|
327
|
-
0,
|
328
|
-
new Diff(DIFF_DELETE, text_delete)
|
329
|
-
);
|
309
|
+
diffs.splice(pointer, 0, new Diff(DIFF_DELETE, text_delete));
|
330
310
|
pointer++;
|
331
311
|
}
|
332
312
|
if (text_insert.length) {
|
333
|
-
diffs.splice(
|
334
|
-
pointer,
|
335
|
-
0,
|
336
|
-
new Diff(DIFF_INSERT, text_insert)
|
337
|
-
);
|
313
|
+
diffs.splice(pointer, 0, new Diff(DIFF_INSERT, text_insert));
|
338
314
|
pointer++;
|
339
315
|
}
|
340
316
|
pointer++;
|
package/dist/error.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { D as DiffOptions } from './types-
|
1
|
+
import { D as DiffOptions } from './types-widbdqe5.js';
|
2
2
|
import 'pretty-format';
|
3
3
|
|
4
|
-
declare function serializeError(val: any, seen?: WeakMap<
|
4
|
+
declare function serializeError(val: any, seen?: WeakMap<WeakKey, any>): any;
|
5
5
|
declare function processError(err: any, diffOptions?: DiffOptions): any;
|
6
|
-
declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<
|
6
|
+
declare function replaceAsymmetricMatcher(actual: any, expected: any, actualReplaced?: WeakSet<WeakKey>, expectedReplaced?: WeakSet<WeakKey>): {
|
7
7
|
replacedActual: any;
|
8
8
|
replacedExpected: any;
|
9
9
|
};
|
package/dist/error.js
CHANGED
@@ -83,7 +83,7 @@ function processError(err, diffOptions) {
|
|
83
83
|
const clonedActual = deepClone(err.actual, { forceWritable: true });
|
84
84
|
const clonedExpected = deepClone(err.expected, { forceWritable: true });
|
85
85
|
const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
|
86
|
-
err.diff = diff(replacedExpected, replacedActual, diffOptions);
|
86
|
+
err.diff = diff(replacedExpected, replacedActual, { ...diffOptions, ...err.diffOptions });
|
87
87
|
}
|
88
88
|
if (typeof err.expected !== "string")
|
89
89
|
err.expected = stringify(err.expected, 10);
|
package/dist/source-map.js
CHANGED
@@ -632,7 +632,7 @@ class TraceMap {
|
|
632
632
|
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
633
633
|
this.version = version;
|
634
634
|
this.file = file;
|
635
|
-
this.names = names;
|
635
|
+
this.names = names || [];
|
636
636
|
this.sourceRoot = sourceRoot;
|
637
637
|
this.sources = sources;
|
638
638
|
this.sourcesContent = sourcesContent;
|
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.
|
4
|
+
"version": "1.0.0-beta.5",
|
5
5
|
"description": "Shared Vitest utility functions",
|
6
6
|
"license": "MIT",
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
@@ -18,23 +18,23 @@
|
|
18
18
|
"exports": {
|
19
19
|
".": {
|
20
20
|
"types": "./dist/index.d.ts",
|
21
|
-
"
|
21
|
+
"default": "./dist/index.js"
|
22
22
|
},
|
23
23
|
"./diff": {
|
24
24
|
"types": "./dist/diff.d.ts",
|
25
|
-
"
|
25
|
+
"default": "./dist/diff.js"
|
26
26
|
},
|
27
27
|
"./error": {
|
28
28
|
"types": "./dist/error.d.ts",
|
29
|
-
"
|
29
|
+
"default": "./dist/error.js"
|
30
30
|
},
|
31
31
|
"./helpers": {
|
32
32
|
"types": "./dist/helpers.d.ts",
|
33
|
-
"
|
33
|
+
"default": "./dist/helpers.js"
|
34
34
|
},
|
35
35
|
"./source-map": {
|
36
36
|
"types": "./dist/source-map.d.ts",
|
37
|
-
"
|
37
|
+
"default": "./dist/source-map.js"
|
38
38
|
},
|
39
39
|
"./*": "./*"
|
40
40
|
},
|
@@ -42,16 +42,16 @@
|
|
42
42
|
"module": "./dist/index.js",
|
43
43
|
"types": "./dist/index.d.ts",
|
44
44
|
"files": [
|
45
|
-
"
|
46
|
-
"
|
45
|
+
"*.d.ts",
|
46
|
+
"dist"
|
47
47
|
],
|
48
48
|
"dependencies": {
|
49
|
-
"diff-sequences": "^29.
|
49
|
+
"diff-sequences": "^29.6.3",
|
50
50
|
"loupe": "^2.3.7",
|
51
|
-
"pretty-format": "^29.
|
51
|
+
"pretty-format": "^29.7.0"
|
52
52
|
},
|
53
53
|
"devDependencies": {
|
54
|
-
"@jridgewell/trace-mapping": "^0.3.
|
54
|
+
"@jridgewell/trace-mapping": "^0.3.20"
|
55
55
|
},
|
56
56
|
"scripts": {
|
57
57
|
"build": "rimraf dist && rollup -c",
|
File without changes
|