@oh-my-pi/pi-utils 15.0.1 → 15.1.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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-utils",
4
- "version": "15.0.1",
4
+ "version": "15.1.0",
5
5
  "description": "Shared utilities for pi packages",
6
- "homepage": "https://github.com/can1357/oh-my-pi",
6
+ "homepage": "https://omp.sh",
7
7
  "author": "Can Boluk",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/bun": "^1.3.14",
41
- "@oh-my-pi/pi-natives": "15.0.1"
41
+ "@oh-my-pi/pi-natives": "15.1.0"
42
42
  },
43
43
  "engines": {
44
44
  "bun": ">=1.3.14"
@@ -96,6 +96,12 @@ export interface FetchWithRetryOptions extends RequestInit {
96
96
  * token refresh or user-agent rotation.
97
97
  */
98
98
  prepareInit?: (attempt: number) => RequestInit | Promise<RequestInit>;
99
+ /**
100
+ * Optional `fetch` implementation override. Defaults to `globalThis.fetch`.
101
+ * Useful for routing requests through a proxy, instrumented transport, or
102
+ * mock during tests.
103
+ */
104
+ fetch?: (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
99
105
  }
100
106
 
101
107
  const DEFAULT_MAX_DELAY_MS = 60_000;
@@ -119,6 +125,7 @@ export async function fetchWithRetry(
119
125
  maxDelayMs = DEFAULT_MAX_DELAY_MS,
120
126
  defaultDelayMs,
121
127
  prepareInit,
128
+ fetch: fetchImpl = fetch,
122
129
  ...baseInit
123
130
  } = options;
124
131
  const signal = baseInit.signal as AbortSignal | undefined;
@@ -130,7 +137,7 @@ export async function fetchWithRetry(
130
137
 
131
138
  let response: Response;
132
139
  try {
133
- response = await fetch(requestUrl, init);
140
+ response = await fetchImpl(requestUrl, init);
134
141
  } catch (error) {
135
142
  if (signal?.aborted) throw new Error("Request was aborted");
136
143
  const wrapped = wrapNetworkError(error);
package/src/postmortem.ts CHANGED
@@ -46,8 +46,7 @@ function runCleanup(reason: Reason): Promise<void> {
46
46
 
47
47
  // Call .cleanup() for each callback that is still "armed".
48
48
  // Use Promise.try to handle sync/async, but only those armed.
49
- // Create a copy to avoid mutating the original array with reverse()
50
- const promises = [...callbackList].reverse().map(callback => {
49
+ const promises = callbackList.toReversed().map(callback => {
51
50
  return Promise.try(() => callback(reason));
52
51
  });
53
52