@mantiq/helpers 0.1.3 → 0.5.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@mantiq/helpers",
3
- "version": "0.1.3",
3
+ "version": "0.5.0",
4
4
  "description": "Str, Arr, Num, Collection utilities",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "LICENSE"
41
41
  ],
42
42
  "scripts": {
43
- "build": "bun build ./src/index.ts --outdir ./dist --target bun",
43
+ "build": "bun build ./src/index.ts --outdir ./dist --target bun --packages=external",
44
44
  "test": "bun test",
45
45
  "typecheck": "tsc --noEmit",
46
46
  "clean": "rm -rf dist"
package/src/Http.ts CHANGED
@@ -54,8 +54,8 @@ export type HttpMiddleware = (
54
54
 
55
55
  export type RetryConfig = {
56
56
  times: number
57
- delay?: string | number
58
- when?: (response: HttpResponse) => boolean
57
+ delay?: string | number | undefined
58
+ when?: ((response: HttpResponse) => boolean) | undefined
59
59
  }
60
60
 
61
61
  // ── PendingRequest (fluent builder) ─────────────────────────────────
@@ -217,7 +217,7 @@ export class PendingRequest {
217
217
  const request = this.buildRequest(method, fullUrl, body)
218
218
 
219
219
  const execute = async (): Promise<HttpResponse<T>> => {
220
- const response = await this.executeWithMiddleware(request.clone())
220
+ const response = await this.executeWithMiddleware(request.clone() as Request)
221
221
  return this.parseResponse<T>(response, fullUrl)
222
222
  }
223
223
 
package/src/HttpFake.ts CHANGED
@@ -169,8 +169,8 @@ export class HttpFake {
169
169
  */
170
170
  install(): this {
171
171
  this.originalFetch = globalThis.fetch
172
- globalThis.fetch = async (input: RequestInfo | URL, init?: RequestInit) => {
173
- const request = input instanceof Request ? input : new Request(input, init)
172
+ const fakeFetch = async (input: string | URL | Request, init?: RequestInit): Promise<Response> => {
173
+ const request = input instanceof Request ? input : (init ? new Request(input as string, init) : new Request(input as string))
174
174
  await this.recordRequest(request)
175
175
  const stub = this.findStub(request)
176
176
 
@@ -184,6 +184,7 @@ export class HttpFake {
184
184
 
185
185
  return this.originalFetch!(input, init)
186
186
  }
187
+ globalThis.fetch = fakeFetch as typeof fetch
187
188
  return this
188
189
  }
189
190