@depup/vitest__utils 4.1.0-depup.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.
@@ -0,0 +1,33 @@
1
+ interface SafeTimers {
2
+ nextTick?: (cb: () => void) => void;
3
+ setImmediate?: {
4
+ <TArgs extends any[]>(callback: (...args: TArgs) => void, ...args: TArgs): any;
5
+ __promisify__: <T = void>(value?: T, options?: any) => Promise<T>;
6
+ };
7
+ clearImmediate?: (immediateId: any) => void;
8
+ setTimeout: typeof setTimeout;
9
+ setInterval: typeof setInterval;
10
+ clearInterval: typeof clearInterval;
11
+ clearTimeout: typeof clearTimeout;
12
+ queueMicrotask: typeof queueMicrotask;
13
+ }
14
+ declare function getSafeTimers(): SafeTimers;
15
+ declare function setSafeTimers(): void;
16
+ /**
17
+ * Returns a promise that resolves after the specified duration.
18
+ *
19
+ * @param timeout - Delay in milliseconds
20
+ * @param scheduler - Timer function to use, defaults to `setTimeout`. Useful for mocked timers.
21
+ *
22
+ * @example
23
+ * await delay(100)
24
+ *
25
+ * @example
26
+ * // With mocked timers
27
+ * const { setTimeout } = getSafeTimers()
28
+ * await delay(100, setTimeout)
29
+ */
30
+ declare function delay(timeout: number, scheduler?: typeof setTimeout): Promise<void>;
31
+
32
+ export { delay, getSafeTimers, setSafeTimers };
33
+ export type { SafeTimers };
package/dist/timers.js ADDED
@@ -0,0 +1,49 @@
1
+ const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS");
2
+ function getSafeTimers() {
3
+ const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
4
+ const { nextTick: safeNextTick } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || {};
5
+ return {
6
+ nextTick: safeNextTick,
7
+ setTimeout: safeSetTimeout,
8
+ setInterval: safeSetInterval,
9
+ clearInterval: safeClearInterval,
10
+ clearTimeout: safeClearTimeout,
11
+ setImmediate: safeSetImmediate,
12
+ clearImmediate: safeClearImmediate,
13
+ queueMicrotask: safeQueueMicrotask
14
+ };
15
+ }
16
+ function setSafeTimers() {
17
+ const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis;
18
+ const { nextTick: safeNextTick } = globalThis.process || {};
19
+ const timers = {
20
+ nextTick: safeNextTick,
21
+ setTimeout: safeSetTimeout,
22
+ setInterval: safeSetInterval,
23
+ clearInterval: safeClearInterval,
24
+ clearTimeout: safeClearTimeout,
25
+ setImmediate: safeSetImmediate,
26
+ clearImmediate: safeClearImmediate,
27
+ queueMicrotask: safeQueueMicrotask
28
+ };
29
+ globalThis[SAFE_TIMERS_SYMBOL] = timers;
30
+ }
31
+ /**
32
+ * Returns a promise that resolves after the specified duration.
33
+ *
34
+ * @param timeout - Delay in milliseconds
35
+ * @param scheduler - Timer function to use, defaults to `setTimeout`. Useful for mocked timers.
36
+ *
37
+ * @example
38
+ * await delay(100)
39
+ *
40
+ * @example
41
+ * // With mocked timers
42
+ * const { setTimeout } = getSafeTimers()
43
+ * await delay(100, setTimeout)
44
+ */
45
+ function delay(timeout, scheduler = setTimeout) {
46
+ return new Promise((resolve) => scheduler(resolve, timeout));
47
+ }
48
+
49
+ export { delay, getSafeTimers, setSafeTimers };
@@ -0,0 +1,53 @@
1
+ import { CompareKeys } from '@vitest/pretty-format';
2
+
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ type DiffOptionsColor = (arg: string) => string;
11
+ interface DiffOptions {
12
+ aAnnotation?: string;
13
+ aColor?: DiffOptionsColor;
14
+ aIndicator?: string;
15
+ bAnnotation?: string;
16
+ bColor?: DiffOptionsColor;
17
+ bIndicator?: string;
18
+ changeColor?: DiffOptionsColor;
19
+ changeLineTrailingSpaceColor?: DiffOptionsColor;
20
+ commonColor?: DiffOptionsColor;
21
+ commonIndicator?: string;
22
+ commonLineTrailingSpaceColor?: DiffOptionsColor;
23
+ contextLines?: number;
24
+ emptyFirstOrLastLinePlaceholder?: string;
25
+ expand?: boolean;
26
+ includeChangeCounts?: boolean;
27
+ omitAnnotationLines?: boolean;
28
+ patchColor?: DiffOptionsColor;
29
+ printBasicPrototype?: boolean;
30
+ maxDepth?: number;
31
+ compareKeys?: CompareKeys;
32
+ truncateThreshold?: number;
33
+ truncateAnnotation?: string;
34
+ truncateAnnotationColor?: DiffOptionsColor;
35
+ }
36
+ interface SerializedDiffOptions {
37
+ aAnnotation?: string;
38
+ aIndicator?: string;
39
+ bAnnotation?: string;
40
+ bIndicator?: string;
41
+ commonIndicator?: string;
42
+ contextLines?: number;
43
+ emptyFirstOrLastLinePlaceholder?: string;
44
+ expand?: boolean;
45
+ includeChangeCounts?: boolean;
46
+ omitAnnotationLines?: boolean;
47
+ printBasicPrototype?: boolean;
48
+ maxDepth?: number;
49
+ truncateThreshold?: number;
50
+ truncateAnnotation?: string;
51
+ }
52
+
53
+ export type { DiffOptions as D, SerializedDiffOptions as S, DiffOptionsColor as a };
@@ -0,0 +1,34 @@
1
+ type Awaitable<T> = T | PromiseLike<T>;
2
+ type Nullable<T> = T | null | undefined;
3
+ type Arrayable<T> = T | Array<T>;
4
+ type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
5
+ type MergeInsertions<T> = T extends object ? { [K in keyof T] : MergeInsertions<T[K]> } : T;
6
+ type DeepMerge<
7
+ F,
8
+ S
9
+ > = MergeInsertions<{ [K in keyof F | keyof S] : K extends keyof S & keyof F ? DeepMerge<F[K], S[K]> : K extends keyof S ? S[K] : K extends keyof F ? F[K] : never }>;
10
+ interface Constructable {
11
+ new (...args: any[]): any;
12
+ }
13
+ interface ParsedStack {
14
+ method: string;
15
+ file: string;
16
+ line: number;
17
+ column: number;
18
+ }
19
+ interface SerializedError {
20
+ message: string;
21
+ stacks?: ParsedStack[];
22
+ stack?: string;
23
+ name?: string;
24
+ cause?: SerializedError;
25
+ [key: string]: unknown;
26
+ }
27
+ interface TestError extends SerializedError {
28
+ cause?: TestError;
29
+ diff?: string;
30
+ actual?: string;
31
+ expected?: string;
32
+ }
33
+
34
+ export type { ArgumentsType, Arrayable, Awaitable, Constructable, DeepMerge, MergeInsertions, Nullable, ParsedStack, SerializedError, TestError };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+
package/error.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/error.js'
package/helpers.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/helpers.js'
package/package.json ADDED
@@ -0,0 +1,123 @@
1
+ {
2
+ "name": "@depup/vitest__utils",
3
+ "type": "module",
4
+ "version": "4.1.0-depup.0",
5
+ "description": "[DepUp] Shared Vitest utility functions",
6
+ "license": "MIT",
7
+ "funding": "https://opencollective.com/vitest",
8
+ "homepage": "https://github.com/vitest-dev/vitest/tree/main/packages/utils",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/vitest-dev/vitest.git",
12
+ "directory": "packages/utils"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/vitest-dev/vitest/issues"
16
+ },
17
+ "sideEffects": false,
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./diff": {
24
+ "types": "./dist/diff.d.ts",
25
+ "default": "./dist/diff.js"
26
+ },
27
+ "./resolver": {
28
+ "types": "./dist/resolver.d.ts",
29
+ "default": "./dist/resolver.js"
30
+ },
31
+ "./error": {
32
+ "types": "./dist/error.d.ts",
33
+ "default": "./dist/error.js"
34
+ },
35
+ "./helpers": {
36
+ "types": "./dist/helpers.d.ts",
37
+ "default": "./dist/helpers.js"
38
+ },
39
+ "./offset": {
40
+ "types": "./dist/offset.d.ts",
41
+ "default": "./dist/offset.js"
42
+ },
43
+ "./constants": {
44
+ "types": "./dist/constants.d.ts",
45
+ "default": "./dist/constants.js"
46
+ },
47
+ "./timers": {
48
+ "types": "./dist/timers.d.ts",
49
+ "default": "./dist/timers.js"
50
+ },
51
+ "./display": {
52
+ "types": "./dist/display.d.ts",
53
+ "default": "./dist/display.js"
54
+ },
55
+ "./source-map": {
56
+ "types": "./dist/source-map.d.ts",
57
+ "default": "./dist/source-map.js"
58
+ },
59
+ "./source-map/node": {
60
+ "types": "./dist/source-map/node.d.ts",
61
+ "default": "./dist/source-map/node.js"
62
+ },
63
+ "./serialize": {
64
+ "types": "./dist/serialize.d.ts",
65
+ "default": "./dist/serialize.js"
66
+ },
67
+ "./*": "./*"
68
+ },
69
+ "main": "./dist/index.js",
70
+ "module": "./dist/index.js",
71
+ "types": "./dist/index.d.ts",
72
+ "typesVersions": {
73
+ "*": {
74
+ "source-map": [
75
+ "dist/source-map.d.ts"
76
+ ],
77
+ "source-map/node": [
78
+ "dist/source-map/node.d.ts"
79
+ ]
80
+ }
81
+ },
82
+ "files": [
83
+ "*.d.ts",
84
+ "dist",
85
+ "changes.json",
86
+ "README.md"
87
+ ],
88
+ "dependencies": {
89
+ "convert-source-map": "^2.0.0",
90
+ "tinyrainbow": "^3.1.0",
91
+ "@vitest/pretty-format": "4.1.0"
92
+ },
93
+ "devDependencies": {
94
+ "@jridgewell/trace-mapping": "0.3.31",
95
+ "@types/convert-source-map": "^2.0.3",
96
+ "@types/estree": "^1.0.8",
97
+ "diff-sequences": "^29.6.3",
98
+ "loupe": "^3.2.1"
99
+ },
100
+ "scripts": {
101
+ "build": "premove dist && rollup -c",
102
+ "dev": "rollup -c --watch"
103
+ },
104
+ "keywords": [
105
+ "depup",
106
+ "dependency-bumped",
107
+ "updated-deps",
108
+ "@vitest/utils"
109
+ ],
110
+ "depup": {
111
+ "changes": {
112
+ "tinyrainbow": {
113
+ "from": "^3.0.3",
114
+ "to": "^3.1.0"
115
+ }
116
+ },
117
+ "depsUpdated": 1,
118
+ "originalPackage": "@vitest/utils",
119
+ "originalVersion": "4.1.0",
120
+ "processedAt": "2026-03-17T16:34:32.931Z",
121
+ "smokeTest": "passed"
122
+ }
123
+ }