@vitest/utils
Advanced tools
+16
-1
@@ -16,4 +16,19 @@ interface SafeTimers { | ||
| declare function setSafeTimers(): void; | ||
| /** | ||
| * Returns a promise that resolves after the specified duration. | ||
| * | ||
| * @param timeout - Delay in milliseconds | ||
| * @param scheduler - Timer function to use, defaults to `setTimeout`. Useful for mocked timers. | ||
| * | ||
| * @example | ||
| * await delay(100) | ||
| * | ||
| * @example | ||
| * // With mocked timers | ||
| * const { setTimeout } = getSafeTimers() | ||
| * await delay(100, setTimeout) | ||
| */ | ||
| declare function delay(timeout: number, scheduler?: typeof setTimeout): Promise<void>; | ||
| export { getSafeTimers, setSafeTimers }; | ||
| export { delay, getSafeTimers, setSafeTimers }; | ||
| export type { SafeTimers }; |
+18
-1
@@ -31,3 +31,20 @@ const SAFE_TIMERS_SYMBOL = Symbol("vitest:SAFE_TIMERS"); | ||
| } | ||
| /** | ||
| * Returns a promise that resolves after the specified duration. | ||
| * | ||
| * @param timeout - Delay in milliseconds | ||
| * @param scheduler - Timer function to use, defaults to `setTimeout`. Useful for mocked timers. | ||
| * | ||
| * @example | ||
| * await delay(100) | ||
| * | ||
| * @example | ||
| * // With mocked timers | ||
| * const { setTimeout } = getSafeTimers() | ||
| * await delay(100, setTimeout) | ||
| */ | ||
| function delay(timeout, scheduler = setTimeout) { | ||
| return new Promise((resolve) => scheduler(resolve, timeout)); | ||
| } | ||
| export { getSafeTimers, setSafeTimers }; | ||
| export { delay, getSafeTimers, setSafeTimers }; |
+2
-2
| { | ||
| "name": "@vitest/utils", | ||
| "type": "module", | ||
| "version": "4.0.14", | ||
| "version": "4.0.15", | ||
| "description": "Shared Vitest utility functions", | ||
@@ -85,3 +85,3 @@ "license": "MIT", | ||
| "tinyrainbow": "^3.0.3", | ||
| "@vitest/pretty-format": "4.0.14" | ||
| "@vitest/pretty-format": "4.0.15" | ||
| }, | ||
@@ -88,0 +88,0 @@ "devDependencies": { |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
179533
0.51%5027
0.64%+ Added
- Removed
Updated