@vitest/utils 0.30.0 → 0.31.0
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/diff.d.ts +1 -0
- package/dist/diff.d.ts +1 -172
- package/dist/diff.js +4 -6
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -6
- package/helpers.d.ts +1 -0
- package/package.json +8 -2
package/diff.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/diff.js'
|
package/dist/diff.d.ts
CHANGED
@@ -1,174 +1,3 @@
|
|
1
|
-
import { DisplayOptions } from 'concordance';
|
2
|
-
|
3
|
-
declare function getConcordanceTheme(): {
|
4
|
-
boolean: {
|
5
|
-
(input: unknown): string;
|
6
|
-
open: string;
|
7
|
-
close: string;
|
8
|
-
};
|
9
|
-
circular: string;
|
10
|
-
date: {
|
11
|
-
invalid: string;
|
12
|
-
value: {
|
13
|
-
(input: unknown): string;
|
14
|
-
open: string;
|
15
|
-
close: string;
|
16
|
-
};
|
17
|
-
};
|
18
|
-
diffGutters: {
|
19
|
-
actual: string;
|
20
|
-
expected: string;
|
21
|
-
padding: string;
|
22
|
-
};
|
23
|
-
error: {
|
24
|
-
ctor: {
|
25
|
-
open: string;
|
26
|
-
close: string;
|
27
|
-
};
|
28
|
-
name: {
|
29
|
-
(input: unknown): string;
|
30
|
-
open: string;
|
31
|
-
close: string;
|
32
|
-
};
|
33
|
-
};
|
34
|
-
function: {
|
35
|
-
name: {
|
36
|
-
(input: unknown): string;
|
37
|
-
open: string;
|
38
|
-
close: string;
|
39
|
-
};
|
40
|
-
stringTag: {
|
41
|
-
(input: unknown): string;
|
42
|
-
open: string;
|
43
|
-
close: string;
|
44
|
-
};
|
45
|
-
};
|
46
|
-
global: {
|
47
|
-
(input: unknown): string;
|
48
|
-
open: string;
|
49
|
-
close: string;
|
50
|
-
};
|
51
|
-
item: {
|
52
|
-
after: string;
|
53
|
-
};
|
54
|
-
list: {
|
55
|
-
openBracket: string;
|
56
|
-
closeBracket: string;
|
57
|
-
};
|
58
|
-
mapEntry: {
|
59
|
-
after: string;
|
60
|
-
};
|
61
|
-
maxDepth: string;
|
62
|
-
null: {
|
63
|
-
(input: unknown): string;
|
64
|
-
open: string;
|
65
|
-
close: string;
|
66
|
-
};
|
67
|
-
number: {
|
68
|
-
(input: unknown): string;
|
69
|
-
open: string;
|
70
|
-
close: string;
|
71
|
-
};
|
72
|
-
object: {
|
73
|
-
openBracket: string;
|
74
|
-
closeBracket: string;
|
75
|
-
ctor: {
|
76
|
-
(input: unknown): string;
|
77
|
-
open: string;
|
78
|
-
close: string;
|
79
|
-
};
|
80
|
-
stringTag: {
|
81
|
-
open: string;
|
82
|
-
close: string;
|
83
|
-
};
|
84
|
-
secondaryStringTag: {
|
85
|
-
open: string;
|
86
|
-
close: string;
|
87
|
-
};
|
88
|
-
};
|
89
|
-
property: {
|
90
|
-
after: string;
|
91
|
-
keyBracket: {
|
92
|
-
open: string;
|
93
|
-
close: string;
|
94
|
-
};
|
95
|
-
valueFallback: string;
|
96
|
-
};
|
97
|
-
regexp: {
|
98
|
-
source: {
|
99
|
-
open: string;
|
100
|
-
close: string;
|
101
|
-
};
|
102
|
-
flags: {
|
103
|
-
(input: unknown): string;
|
104
|
-
open: string;
|
105
|
-
close: string;
|
106
|
-
};
|
107
|
-
};
|
108
|
-
stats: {
|
109
|
-
separator: string;
|
110
|
-
};
|
111
|
-
string: {
|
112
|
-
open: string;
|
113
|
-
close: string;
|
114
|
-
line: {
|
115
|
-
open: string;
|
116
|
-
close: string;
|
117
|
-
};
|
118
|
-
multiline: {
|
119
|
-
start: string;
|
120
|
-
end: string;
|
121
|
-
};
|
122
|
-
controlPicture: {
|
123
|
-
(input: unknown): string;
|
124
|
-
open: string;
|
125
|
-
close: string;
|
126
|
-
};
|
127
|
-
diff: {
|
128
|
-
insert: {
|
129
|
-
open: string;
|
130
|
-
close: string;
|
131
|
-
};
|
132
|
-
delete: {
|
133
|
-
open: string;
|
134
|
-
close: string;
|
135
|
-
};
|
136
|
-
equal: {
|
137
|
-
(input: unknown): string;
|
138
|
-
open: string;
|
139
|
-
close: string;
|
140
|
-
};
|
141
|
-
insertLine: {
|
142
|
-
open: string;
|
143
|
-
close: string;
|
144
|
-
};
|
145
|
-
deleteLine: {
|
146
|
-
open: string;
|
147
|
-
close: string;
|
148
|
-
};
|
149
|
-
};
|
150
|
-
};
|
151
|
-
symbol: {
|
152
|
-
(input: unknown): string;
|
153
|
-
open: string;
|
154
|
-
close: string;
|
155
|
-
};
|
156
|
-
typedArray: {
|
157
|
-
bytes: {
|
158
|
-
(input: unknown): string;
|
159
|
-
open: string;
|
160
|
-
close: string;
|
161
|
-
};
|
162
|
-
};
|
163
|
-
undefined: {
|
164
|
-
(input: unknown): string;
|
165
|
-
open: string;
|
166
|
-
close: string;
|
167
|
-
};
|
168
|
-
};
|
169
|
-
declare function diffDescriptors(actual: unknown, expected: unknown, options: DisplayOptions): string;
|
170
|
-
declare function formatDescriptor(value: unknown, options: DisplayOptions): string;
|
171
|
-
|
172
1
|
interface DiffOptions {
|
173
2
|
showLegend?: boolean;
|
174
3
|
}
|
@@ -182,4 +11,4 @@ interface DiffOptions {
|
|
182
11
|
*/
|
183
12
|
declare function unifiedDiff(actual: unknown, expected: unknown, options?: DiffOptions): string;
|
184
13
|
|
185
|
-
export { DiffOptions,
|
14
|
+
export { DiffOptions, unifiedDiff };
|
package/dist/diff.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { b as getColors } from './chunk-colors.js';
|
2
|
-
import concordance from 'concordance';
|
2
|
+
import * as concordance from 'concordance';
|
3
3
|
|
4
|
+
const concordanceModule = "default" in concordance ? concordance.default : concordance;
|
4
5
|
function getConcordanceTheme() {
|
5
6
|
const c = getColors();
|
6
7
|
return {
|
@@ -81,10 +82,7 @@ function getConcordanceTheme() {
|
|
81
82
|
};
|
82
83
|
}
|
83
84
|
function diffDescriptors(actual, expected, options) {
|
84
|
-
return
|
85
|
-
}
|
86
|
-
function formatDescriptor(value, options) {
|
87
|
-
return concordance.formatDescriptor(value, options);
|
85
|
+
return concordanceModule.diff(expected, actual, options);
|
88
86
|
}
|
89
87
|
|
90
88
|
function unifiedDiff(actual, expected, options = {}) {
|
@@ -115,4 +113,4 @@ function unifiedDiff(actual, expected, options = {}) {
|
|
115
113
|
return legend + diff.replace(/␊\s*$/mg, "");
|
116
114
|
}
|
117
115
|
|
118
|
-
export {
|
116
|
+
export { unifiedDiff };
|
package/dist/index.d.ts
CHANGED
@@ -21,10 +21,13 @@ declare function setSafeTimers(): void;
|
|
21
21
|
|
22
22
|
declare function shuffle<T>(array: T[], seed?: number): T[];
|
23
23
|
|
24
|
+
interface LoupeOptions {
|
25
|
+
truncateThreshold?: number;
|
26
|
+
}
|
24
27
|
declare function format(...args: any[]): string;
|
25
28
|
declare function utilInspect(item: unknown, options?: util.InspectOptions): string;
|
26
|
-
declare function loupeInspect(obj: unknown): string;
|
27
|
-
declare function objDisplay(obj: unknown): string;
|
29
|
+
declare function loupeInspect(obj: unknown, options?: LoupeOptions): string;
|
30
|
+
declare function objDisplay(obj: unknown, options?: LoupeOptions): string;
|
28
31
|
|
29
32
|
declare const SAFE_TIMERS_SYMBOL: unique symbol;
|
30
33
|
declare const SAFE_COLORS_SYMBOL: unique symbol;
|
package/dist/index.js
CHANGED
@@ -116,17 +116,17 @@ function format(...args) {
|
|
116
116
|
function utilInspect(item, options) {
|
117
117
|
return util.inspect(item, options);
|
118
118
|
}
|
119
|
-
function loupeInspect(obj) {
|
119
|
+
function loupeInspect(obj, options = {}) {
|
120
120
|
return loupe(obj, {
|
121
121
|
depth: 2,
|
122
|
-
truncate: 40
|
122
|
+
truncate: options.truncateThreshold === 0 ? Infinity : options.truncateThreshold ?? 40
|
123
123
|
});
|
124
124
|
}
|
125
|
-
function objDisplay(obj) {
|
126
|
-
const truncateThreshold = 40;
|
127
|
-
const str = loupeInspect(obj);
|
125
|
+
function objDisplay(obj, options = {}) {
|
126
|
+
const truncateThreshold = options.truncateThreshold ?? 40;
|
127
|
+
const str = loupeInspect(obj, options);
|
128
128
|
const type = Object.prototype.toString.call(obj);
|
129
|
-
if (str.length >= truncateThreshold) {
|
129
|
+
if (truncateThreshold && str.length >= truncateThreshold) {
|
130
130
|
if (type === "[object Function]") {
|
131
131
|
const fn = obj;
|
132
132
|
return !fn.name || fn.name === "" ? "[Function]" : `[Function: ${fn.name}]`;
|
package/helpers.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/helpers.js'
|
package/package.json
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.31.0",
|
5
5
|
"description": "Shared Vitest utility functions",
|
6
6
|
"license": "MIT",
|
7
|
+
"funding": "https://opencollective.com/vitest",
|
8
|
+
"homepage": "https://github.com/vitest-dev/vitest/tree/main/packages/utils#readme",
|
7
9
|
"repository": {
|
8
10
|
"type": "git",
|
9
11
|
"url": "git+https://github.com/vitest-dev/vitest.git",
|
10
12
|
"directory": "packages/utils"
|
11
13
|
},
|
14
|
+
"bugs": {
|
15
|
+
"url": "https://github.com/vitest-dev/vitest/issues"
|
16
|
+
},
|
12
17
|
"sideEffects": false,
|
13
18
|
"exports": {
|
14
19
|
".": {
|
@@ -29,7 +34,8 @@
|
|
29
34
|
"module": "./dist/index.js",
|
30
35
|
"types": "./dist/index.d.ts",
|
31
36
|
"files": [
|
32
|
-
"dist"
|
37
|
+
"dist",
|
38
|
+
"*.d.ts"
|
33
39
|
],
|
34
40
|
"dependencies": {
|
35
41
|
"concordance": "^5.0.4",
|