@ahoo-wang/fetcher 1.3.2 → 1.3.5

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/dist/timeout.d.ts CHANGED
@@ -55,15 +55,17 @@ export interface TimeoutCapable {
55
55
  */
56
56
  export declare function resolveTimeout(requestTimeout?: number, optionsTimeout?: number): number | undefined;
57
57
  /**
58
- * HTTP request method with timeout control.
58
+ * Executes an HTTP request with optional timeout support.
59
59
  *
60
- * Uses Promise.race to implement timeout control, initiating both
61
- * fetch request and timeout Promise simultaneously. When either Promise completes,
62
- * it returns the result or throws an exception.
60
+ * This function provides a wrapper around the native fetch API with added timeout functionality.
61
+ * - If a timeout is specified, it will create an AbortController to cancel the request if it exceeds the timeout.
62
+ * - If the request already has a signal, it will delegate to the native fetch API directly to avoid conflicts.
63
+ * - If the request has an abortController, it will be used instead of creating a new one.
63
64
  *
64
- * @param request - The request initialization options
65
- * @returns Promise<Response> HTTP response Promise
66
- * @throws FetchTimeoutError Thrown when the request times out
65
+ * @param request - The request configuration including URL, method, headers, body, and optional timeout
66
+ * @returns Promise that resolves to the Response object
67
+ * @throws FetchTimeoutError if the request times out
68
+ * @throws TypeError for network errors
67
69
  *
68
70
  * @example
69
71
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../src/timeout.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iBAAkB,SAAQ,YAAY;IACjD;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IAEtB;;;;OAIG;gBACS,OAAO,EAAE,YAAY;CASlC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,cAAc,CAAC,EAAE,MAAM,EACvB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,GAAG,SAAS,CAKpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyC3E"}
1
+ {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../src/timeout.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iBAAkB,SAAQ,YAAY;IACjD;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC;IAEtB;;;;OAIG;gBACS,OAAO,EAAE,YAAY;CASlC;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,cAAc,CAAC,EAAE,MAAM,EACvB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM,GAAG,SAAS,CAKpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CA+C3E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ahoo-wang/fetcher",
3
- "version": "1.3.2",
3
+ "version": "1.3.5",
4
4
  "description": "Ultra-lightweight (2.8KiB min+gzip) HTTP client with built-in path parameters, query parameters, and Axios-like API. The foundation of the Fetcher ecosystem with powerful interceptor system and LLM streaming API support.",
5
5
  "keywords": [
6
6
  "fetch",