@oh-my-pi/pi-utils 13.17.1 → 13.17.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/abortable.ts +8 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "13.17.1",
4
+ "version": "13.17.6",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://github.com/can1357/oh-my-pi",
7
7
  "author": "Can Boluk",
package/src/abortable.ts CHANGED
@@ -12,9 +12,15 @@ export class AbortError extends Error {
12
12
 
13
13
  /**
14
14
  * Sleep for a given number of milliseconds, respecting abort signal.
15
+ *
16
+ * Uses setTimeout (not Bun.sleep) so that vitest fake timers can intercept it in tests.
15
17
  */
16
- export async function abortableSleep(ms: number, signal?: AbortSignal): Promise<void> {
17
- return untilAborted(signal, () => Bun.sleep(ms));
18
+ export function abortableSleep(ms: number, signal?: AbortSignal): Promise<void> {
19
+ return untilAborted(signal, () => {
20
+ const { promise, resolve } = Promise.withResolvers<void>();
21
+ setTimeout(resolve, ms);
22
+ return promise;
23
+ });
18
24
  }
19
25
 
20
26
  /**