@happy-ts/fetch-t 1.3.2 → 1.4.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,35 +1,42 @@
1
1
  {
2
2
  "name": "@happy-ts/fetch-t",
3
- "description": "Abortable fetch wrapper with the ability to specify the return type.",
3
+ "description": "Type-safe Fetch API wrapper with abortable requests, timeout support, progress tracking, and Rust-like Result error handling.",
4
4
  "author": "jiang115jie@gmail.com",
5
- "license": "GPL-3.0",
6
- "version": "1.3.2",
5
+ "license": "MIT",
6
+ "version": "1.4.0",
7
7
  "type": "module",
8
8
  "source": "src/mod.ts",
9
9
  "main": "dist/main.cjs",
10
10
  "module": "dist/main.mjs",
11
11
  "types": "dist/types.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/types.d.ts",
15
+ "import": "./dist/main.mjs",
16
+ "require": "./dist/main.cjs",
17
+ "default": "./dist/main.mjs"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
12
21
  "files": [
13
22
  "LICENSE",
14
23
  "README.md",
15
24
  "README.cn.md",
16
- "package.json",
17
- "docs",
18
- "src",
25
+ "CHANGELOG.md",
19
26
  "dist"
20
27
  ],
21
28
  "sideEffects": false,
22
29
  "scripts": {
23
30
  "check": "pnpm exec tsc --noEmit",
24
31
  "lint": "pnpm exec eslint .",
25
- "prebuild": "pnpm dlx rimraf dist && pnpm run check && pnpm run lint",
26
- "build": "pnpm exec rollup --config rollup.config.mjs",
27
- "pretest": "pnpm dlx rimraf coverage",
28
- "test": "deno test -A --coverage && deno coverage coverage && deno coverage coverage --lcov --output=coverage/cov_profile.lcov",
29
- "pretest:html": "pnpm run pretest",
30
- "test:html": "deno test -A --coverage && deno coverage coverage && deno coverage coverage --html",
32
+ "prebuild": "pnpm run check && pnpm run lint",
33
+ "build": "pnpm exec vite build",
34
+ "test": "pnpm exec vitest run --coverage",
35
+ "test:watch": "pnpm exec vitest",
36
+ "test:ui": "pnpm exec vitest --ui",
31
37
  "predocs": "pnpm dlx rimraf docs",
32
38
  "docs": "pnpm exec typedoc",
39
+ "eg": "node examples/main.ts",
33
40
  "prepublishOnly": "pnpm run build"
34
41
  },
35
42
  "repository": {
@@ -40,23 +47,29 @@
40
47
  "fetch",
41
48
  "abort",
42
49
  "cancel",
43
- "responseType"
50
+ "timeout",
51
+ "progress",
52
+ "streaming",
53
+ "type-safe",
54
+ "typescript",
55
+ "result",
56
+ "async"
44
57
  ],
45
58
  "devDependencies": {
46
- "@eslint/js": "^9.9.0",
47
- "@types/eslint__js": "^8.42.3",
48
- "eslint": "^9.9.0",
49
- "rollup": "^4.20.0",
50
- "rollup-plugin-dts": "^6.1.1",
51
- "rollup-plugin-esbuild": "^6.1.1",
52
- "typedoc": "^0.26.5",
53
- "typedoc-plugin-markdown": "^4.2.3",
54
- "typescript": "^5.5.4",
55
- "typescript-eslint": "^8.0.1"
59
+ "@eslint/js": "^9.39.2",
60
+ "@stylistic/eslint-plugin": "^5.6.1",
61
+ "@vitest/coverage-v8": "^4.0.16",
62
+ "eslint": "^9.39.2",
63
+ "msw": "^2.12.4",
64
+ "typedoc": "^0.28.15",
65
+ "typescript": "^5.9.3",
66
+ "typescript-eslint": "^8.50.0",
67
+ "vite": "^7.3.0",
68
+ "vite-plugin-dts": "^4.5.4",
69
+ "vitest": "^4.0.16"
56
70
  },
57
71
  "dependencies": {
58
- "happy-rusty": "^1.5.0",
72
+ "happy-rusty": "^1.6.1",
59
73
  "tiny-invariant": "^1.3.3"
60
- },
61
- "packageManager": "pnpm@9.7.0"
74
+ }
62
75
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/docs/README.md DELETED
@@ -1,39 +0,0 @@
1
- **@happy-ts/fetch-t** • **Docs**
2
-
3
- ***
4
-
5
- # @happy-ts/fetch-t
6
-
7
- ## Classes
8
-
9
- | Class | Description |
10
- | ------ | ------ |
11
- | [FetchError](classes/FetchError.md) | Represents an error that occurred during a fetch operation when the response is not ok. |
12
-
13
- ## Interfaces
14
-
15
- | Interface | Description |
16
- | ------ | ------ |
17
- | [FetchInit](interfaces/FetchInit.md) | Extends the standard `RequestInit` interface from the Fetch API to include additional custom options. |
18
- | [FetchProgress](interfaces/FetchProgress.md) | Represents the progress of a fetch operation. |
19
- | [FetchTask](interfaces/FetchTask.md) | Defines the structure and behavior of a fetch task, including the ability to abort the task and check its status. |
20
-
21
- ## Type Aliases
22
-
23
- | Type alias | Description |
24
- | ------ | ------ |
25
- | [FetchResponse](type-aliases/FetchResponse.md) | Represents the response of a fetch operation, encapsulating the result data or any error that occurred. |
26
- | [FetchResponseType](type-aliases/FetchResponseType.md) | Specifies the expected response type of the fetch request. |
27
-
28
- ## Variables
29
-
30
- | Variable | Description |
31
- | ------ | ------ |
32
- | [ABORT\_ERROR](variables/ABORT_ERROR.md) | Name of abort error; |
33
- | [TIMEOUT\_ERROR](variables/TIMEOUT_ERROR.md) | Name of timeout error; |
34
-
35
- ## Functions
36
-
37
- | Function | Description |
38
- | ------ | ------ |
39
- | [fetchT](functions/fetchT.md) | Fetches a resource from the network as a text string and returns a `FetchTask` representing the operation. |
@@ -1,47 +0,0 @@
1
- [**@happy-ts/fetch-t**](../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [@happy-ts/fetch-t](../README.md) / FetchError
6
-
7
- # Class: FetchError
8
-
9
- Represents an error that occurred during a fetch operation when the response is not ok.
10
-
11
- ## Extends
12
-
13
- - `Error`
14
-
15
- ## Constructors
16
-
17
- ### new FetchError()
18
-
19
- ```ts
20
- new FetchError(message, status): FetchError
21
- ```
22
-
23
- #### Parameters
24
-
25
- | Parameter | Type |
26
- | ------ | ------ |
27
- | `message` | `string` |
28
- | `status` | `number` |
29
-
30
- #### Returns
31
-
32
- [`FetchError`](FetchError.md)
33
-
34
- #### Overrides
35
-
36
- `Error.constructor`
37
-
38
- #### Defined in
39
-
40
- [defines.ts:100](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L100)
41
-
42
- ## Properties
43
-
44
- | Property | Type | Default value | Description | Overrides | Defined in |
45
- | ------ | ------ | ------ | ------ | ------ | ------ |
46
- | `name` | `string` | `'FetchError'` | The name of the error. | `Error.name` | [defines.ts:94](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L94) |
47
- | `status` | `number` | `0` | The status code of the response. | - | [defines.ts:98](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L98) |
@@ -1,423 +0,0 @@
1
- [**@happy-ts/fetch-t**](../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [@happy-ts/fetch-t](../README.md) / fetchT
6
-
7
- # Function: fetchT()
8
-
9
- Fetches a resource from the network and returns either a `FetchTask` or `FetchResponse` based on the provided options.
10
-
11
- ## Type Param
12
-
13
- The expected type of the response data when not using a specific `responseType`.
14
-
15
- ## Param
16
-
17
- The resource to fetch. Can be a URL object or a string representing a URL.
18
-
19
- ## Param
20
-
21
- Additional options for the fetch operation, including custom `FetchInit` properties.
22
-
23
- ## fetchT(url, init)
24
-
25
- ```ts
26
- function fetchT(url, init): FetchTask<string>
27
- ```
28
-
29
- Fetches a resource from the network as a text string and returns a `FetchTask` representing the operation.
30
-
31
- ### Parameters
32
-
33
- | Parameter | Type | Description |
34
- | ------ | ------ | ------ |
35
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
36
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"text"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
37
-
38
- ### Returns
39
-
40
- [`FetchTask`](../interfaces/FetchTask.md)\<`string`\>
41
-
42
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
43
-
44
- A `FetchTask` representing the operation with a `string` response.
45
-
46
- ### Type Param
47
-
48
- The expected type of the response data when not using a specific `responseType`.
49
-
50
- ### Param
51
-
52
- The resource to fetch. Can be a URL object or a string representing a URL.
53
-
54
- ### Param
55
-
56
- Additional options for the fetch operation, including custom `FetchInit` properties.
57
-
58
- ### Defined in
59
-
60
- [fetch.ts:14](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L14)
61
-
62
- ## fetchT(url, init)
63
-
64
- ```ts
65
- function fetchT(url, init): FetchTask<ArrayBuffer>
66
- ```
67
-
68
- Fetches a resource from the network as an ArrayBuffer and returns a `FetchTask` representing the operation.
69
-
70
- ### Parameters
71
-
72
- | Parameter | Type | Description |
73
- | ------ | ------ | ------ |
74
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
75
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"arraybuffer"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
76
-
77
- ### Returns
78
-
79
- [`FetchTask`](../interfaces/FetchTask.md)\<`ArrayBuffer`\>
80
-
81
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
82
-
83
- A `FetchTask` representing the operation with an `ArrayBuffer` response.
84
-
85
- ### Type Param
86
-
87
- The expected type of the response data when not using a specific `responseType`.
88
-
89
- ### Param
90
-
91
- The resource to fetch. Can be a URL object or a string representing a URL.
92
-
93
- ### Param
94
-
95
- Additional options for the fetch operation, including custom `FetchInit` properties.
96
-
97
- ### Defined in
98
-
99
- [fetch.ts:26](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L26)
100
-
101
- ## fetchT(url, init)
102
-
103
- ```ts
104
- function fetchT(url, init): FetchTask<Blob>
105
- ```
106
-
107
- Fetches a resource from the network as a Blob and returns a `FetchTask` representing the operation.
108
-
109
- ### Parameters
110
-
111
- | Parameter | Type | Description |
112
- | ------ | ------ | ------ |
113
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
114
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"blob"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
115
-
116
- ### Returns
117
-
118
- [`FetchTask`](../interfaces/FetchTask.md)\<`Blob`\>
119
-
120
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
121
-
122
- A `FetchTask` representing the operation with a `Blob` response.
123
-
124
- ### Type Param
125
-
126
- The expected type of the response data when not using a specific `responseType`.
127
-
128
- ### Param
129
-
130
- The resource to fetch. Can be a URL object or a string representing a URL.
131
-
132
- ### Param
133
-
134
- Additional options for the fetch operation, including custom `FetchInit` properties.
135
-
136
- ### Defined in
137
-
138
- [fetch.ts:38](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L38)
139
-
140
- ## fetchT(url, init)
141
-
142
- ```ts
143
- function fetchT<T>(url, init): FetchTask<T>
144
- ```
145
-
146
- Fetches a resource from the network and parses it as JSON, returning a `FetchTask` representing the operation.
147
-
148
- ### Type Parameters
149
-
150
- | Type Parameter | Description |
151
- | ------ | ------ |
152
- | `T` | The expected type of the parsed JSON data. |
153
-
154
- ### Parameters
155
-
156
- | Parameter | Type | Description |
157
- | ------ | ------ | ------ |
158
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
159
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"json"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
160
-
161
- ### Returns
162
-
163
- [`FetchTask`](../interfaces/FetchTask.md)\<`T`\>
164
-
165
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
166
-
167
- A `FetchTask` representing the operation with a response parsed as JSON.
168
-
169
- ### Type Param
170
-
171
- The expected type of the response data when not using a specific `responseType`.
172
-
173
- ### Param
174
-
175
- The resource to fetch. Can be a URL object or a string representing a URL.
176
-
177
- ### Param
178
-
179
- Additional options for the fetch operation, including custom `FetchInit` properties.
180
-
181
- ### Defined in
182
-
183
- [fetch.ts:51](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L51)
184
-
185
- ## fetchT(url, init)
186
-
187
- ```ts
188
- function fetchT(url, init): FetchResponse<string, Error>
189
- ```
190
-
191
- Fetches a resource from the network as a text string and returns a `FetchResponse` representing the operation.
192
-
193
- ### Parameters
194
-
195
- | Parameter | Type | Description |
196
- | ------ | ------ | ------ |
197
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
198
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"text"`; \} | Additional options for the fetch operation, specifying the response type as 'text'. |
199
-
200
- ### Returns
201
-
202
- [`FetchResponse`](../type-aliases/FetchResponse.md)\<`string`, `Error`\>
203
-
204
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
205
-
206
- A `FetchResponse` representing the operation with a `string` response.
207
-
208
- ### Type Param
209
-
210
- The expected type of the response data when not using a specific `responseType`.
211
-
212
- ### Param
213
-
214
- The resource to fetch. Can be a URL object or a string representing a URL.
215
-
216
- ### Param
217
-
218
- Additional options for the fetch operation, including custom `FetchInit` properties.
219
-
220
- ### Defined in
221
-
222
- [fetch.ts:63](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L63)
223
-
224
- ## fetchT(url, init)
225
-
226
- ```ts
227
- function fetchT(url, init): FetchResponse<ArrayBuffer, Error>
228
- ```
229
-
230
- Fetches a resource from the network as an ArrayBuffer and returns a `FetchResponse` representing the operation.
231
-
232
- ### Parameters
233
-
234
- | Parameter | Type | Description |
235
- | ------ | ------ | ------ |
236
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
237
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"arraybuffer"`; \} | Additional options for the fetch operation, specifying the response type as 'arraybuffer'. |
238
-
239
- ### Returns
240
-
241
- [`FetchResponse`](../type-aliases/FetchResponse.md)\<`ArrayBuffer`, `Error`\>
242
-
243
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
244
-
245
- A `FetchResponse` representing the operation with an `ArrayBuffer` response.
246
-
247
- ### Type Param
248
-
249
- The expected type of the response data when not using a specific `responseType`.
250
-
251
- ### Param
252
-
253
- The resource to fetch. Can be a URL object or a string representing a URL.
254
-
255
- ### Param
256
-
257
- Additional options for the fetch operation, including custom `FetchInit` properties.
258
-
259
- ### Defined in
260
-
261
- [fetch.ts:74](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L74)
262
-
263
- ## fetchT(url, init)
264
-
265
- ```ts
266
- function fetchT(url, init): FetchResponse<Blob, Error>
267
- ```
268
-
269
- Fetches a resource from the network as a Blob and returns a `FetchResponse` representing the operation.
270
-
271
- ### Parameters
272
-
273
- | Parameter | Type | Description |
274
- | ------ | ------ | ------ |
275
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
276
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"blob"`; \} | Additional options for the fetch operation, specifying the response type as 'blob'. |
277
-
278
- ### Returns
279
-
280
- [`FetchResponse`](../type-aliases/FetchResponse.md)\<`Blob`, `Error`\>
281
-
282
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
283
-
284
- A `FetchResponse` representing the operation with a `Blob` response.
285
-
286
- ### Type Param
287
-
288
- The expected type of the response data when not using a specific `responseType`.
289
-
290
- ### Param
291
-
292
- The resource to fetch. Can be a URL object or a string representing a URL.
293
-
294
- ### Param
295
-
296
- Additional options for the fetch operation, including custom `FetchInit` properties.
297
-
298
- ### Defined in
299
-
300
- [fetch.ts:85](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L85)
301
-
302
- ## fetchT(url, init)
303
-
304
- ```ts
305
- function fetchT<T>(url, init): FetchResponse<T, Error>
306
- ```
307
-
308
- Fetches a resource from the network and parses it as JSON, returning a `FetchResponse` representing the operation.
309
-
310
- ### Type Parameters
311
-
312
- | Type Parameter | Description |
313
- | ------ | ------ |
314
- | `T` | The expected type of the parsed JSON data. |
315
-
316
- ### Parameters
317
-
318
- | Parameter | Type | Description |
319
- | ------ | ------ | ------ |
320
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
321
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"json"`; \} | Additional options for the fetch operation, specifying the response type as 'json'. |
322
-
323
- ### Returns
324
-
325
- [`FetchResponse`](../type-aliases/FetchResponse.md)\<`T`, `Error`\>
326
-
327
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
328
-
329
- A `FetchResponse` representing the operation with a response parsed as JSON.
330
-
331
- ### Type Param
332
-
333
- The expected type of the response data when not using a specific `responseType`.
334
-
335
- ### Param
336
-
337
- The resource to fetch. Can be a URL object or a string representing a URL.
338
-
339
- ### Param
340
-
341
- Additional options for the fetch operation, including custom `FetchInit` properties.
342
-
343
- ### Defined in
344
-
345
- [fetch.ts:97](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L97)
346
-
347
- ## fetchT(url, init)
348
-
349
- ```ts
350
- function fetchT(url, init): FetchTask<Response>
351
- ```
352
-
353
- Fetches a resource from the network and returns a `FetchTask` representing the operation with a generic `Response`.
354
-
355
- ### Parameters
356
-
357
- | Parameter | Type | Description |
358
- | ------ | ------ | ------ |
359
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
360
- | `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; \} | Additional options for the fetch operation, indicating that the operation should be abortable. |
361
-
362
- ### Returns
363
-
364
- [`FetchTask`](../interfaces/FetchTask.md)\<`Response`\>
365
-
366
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
367
-
368
- A `FetchTask` representing the operation with a generic `Response`.
369
-
370
- ### Type Param
371
-
372
- The expected type of the response data when not using a specific `responseType`.
373
-
374
- ### Param
375
-
376
- The resource to fetch. Can be a URL object or a string representing a URL.
377
-
378
- ### Param
379
-
380
- Additional options for the fetch operation, including custom `FetchInit` properties.
381
-
382
- ### Defined in
383
-
384
- [fetch.ts:108](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L108)
385
-
386
- ## fetchT(url, init)
387
-
388
- ```ts
389
- function fetchT(url, init?): FetchResponse<Response>
390
- ```
391
-
392
- Fetches a resource from the network and returns a `FetchResponse` or `FetchTask` based on the provided options.
393
-
394
- ### Parameters
395
-
396
- | Parameter | Type | Description |
397
- | ------ | ------ | ------ |
398
- | `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
399
- | `init`? | [`FetchInit`](../interfaces/FetchInit.md) | Additional options for the fetch operation, including custom `FetchInit` properties. |
400
-
401
- ### Returns
402
-
403
- [`FetchResponse`](../type-aliases/FetchResponse.md)\<`Response`\>
404
-
405
- A `FetchTask` or `FetchResponse` depending on the provided options in `init`.
406
-
407
- A `FetchResponse` representing the operation with a `Response` object.
408
-
409
- ### Type Param
410
-
411
- The expected type of the response data when not using a specific `responseType`.
412
-
413
- ### Param
414
-
415
- The resource to fetch. Can be a URL object or a string representing a URL.
416
-
417
- ### Param
418
-
419
- Additional options for the fetch operation, including custom `FetchInit` properties.
420
-
421
- ### Defined in
422
-
423
- [fetch.ts:120](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/fetch.ts#L120)
@@ -1,23 +0,0 @@
1
- [**@happy-ts/fetch-t**](../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [@happy-ts/fetch-t](../README.md) / FetchInit
6
-
7
- # Interface: FetchInit
8
-
9
- Extends the standard `RequestInit` interface from the Fetch API to include additional custom options.
10
-
11
- ## Extends
12
-
13
- - `RequestInit`
14
-
15
- ## Properties
16
-
17
- | Property | Type | Description | Defined in |
18
- | ------ | ------ | ------ | ------ |
19
- | `abortable?` | `boolean` | Indicates whether the fetch request should be abortable. | [defines.ts:62](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L62) |
20
- | `onChunk?` | (`chunk`: `Uint8Array`) => `void` | Specifies a function to be called when the fetch request receives a chunk of data. | [defines.ts:84](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L84) |
21
- | `onProgress?` | (`progressResult`: `IOResult`\<[`FetchProgress`](FetchProgress.md)\>) => `void` | Specifies a function to be called when the fetch request makes progress. | [defines.ts:78](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L78) |
22
- | `responseType?` | [`FetchResponseType`](../type-aliases/FetchResponseType.md) | Specifies the expected response type of the fetch request. | [defines.ts:67](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L67) |
23
- | `timeout?` | `number` | Specifies the maximum time in milliseconds to wait for the fetch request to complete. | [defines.ts:72](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L72) |
@@ -1,16 +0,0 @@
1
- [**@happy-ts/fetch-t**](../README.md) • **Docs**
2
-
3
- ***
4
-
5
- [@happy-ts/fetch-t](../README.md) / FetchProgress
6
-
7
- # Interface: FetchProgress
8
-
9
- Represents the progress of a fetch operation.
10
-
11
- ## Properties
12
-
13
- | Property | Type | Description | Defined in |
14
- | ------ | ------ | ------ | ------ |
15
- | `completedByteLength` | `number` | The number of bytes received so far. | [defines.ts:52](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L52) |
16
- | `totalByteLength` | `number` | The total number of bytes to be received. | [defines.ts:47](https://github.com/JiangJie/fetch-t/blob/61346c95bab5342bcbd9e97bca747ef24af2eac6/src/fetch/defines.ts#L47) |