@happy-ts/fetch-t 1.0.9 → 1.0.10
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/README.cn.md +1 -1
- package/README.md +1 -1
- package/docs/{index.md → README.md} +3 -3
- package/docs/functions/fetchT.md +61 -47
- package/docs/interfaces/FetchInit.md +20 -20
- package/docs/interfaces/FetchTask.md +12 -12
- package/docs/type-aliases/FetchResponse.md +8 -8
- package/package.json +9 -9
package/README.cn.md
CHANGED
package/README.md
CHANGED
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
## Interfaces
|
|
8
8
|
|
|
9
9
|
| Interface | Description |
|
|
10
|
-
|
|
|
10
|
+
| ------ | ------ |
|
|
11
11
|
| [FetchInit](interfaces/FetchInit.md) | Extends the standard `RequestInit` interface from the Fetch API to include additional custom options. |
|
|
12
12
|
| [FetchTask](interfaces/FetchTask.md) | Defines the structure and behavior of a fetch task, including the ability to abort the task and check its status. |
|
|
13
13
|
|
|
14
14
|
## Type Aliases
|
|
15
15
|
|
|
16
16
|
| Type alias | Description |
|
|
17
|
-
|
|
|
17
|
+
| ------ | ------ |
|
|
18
18
|
| [FetchResponse](type-aliases/FetchResponse.md) | Represents the response of a fetch operation, encapsulating the result data or any error that occurred. |
|
|
19
19
|
|
|
20
20
|
## Functions
|
|
21
21
|
|
|
22
22
|
| Function | Description |
|
|
23
|
-
|
|
|
23
|
+
| ------ | ------ |
|
|
24
24
|
| [fetchT](functions/fetchT.md) | Fetches a resource from the network as a text string and returns a `FetchTask` representing the operation. |
|
package/docs/functions/fetchT.md
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
[**@happy-ts/fetch-t**](../
|
|
1
|
+
[**@happy-ts/fetch-t**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@happy-ts/fetch-t](../
|
|
5
|
+
[@happy-ts/fetch-t](../README.md) / fetchT
|
|
6
6
|
|
|
7
7
|
# Function: fetchT()
|
|
8
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
|
+
|
|
9
23
|
## fetchT(url, init)
|
|
10
24
|
|
|
11
25
|
```ts
|
|
@@ -17,7 +31,7 @@ Fetches a resource from the network as a text string and returns a `FetchTask` r
|
|
|
17
31
|
### Parameters
|
|
18
32
|
|
|
19
33
|
| Parameter | Type | Description |
|
|
20
|
-
|
|
|
34
|
+
| ------ | ------ | ------ |
|
|
21
35
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
22
36
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"text"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
|
|
23
37
|
|
|
@@ -27,9 +41,9 @@ Fetches a resource from the network as a text string and returns a `FetchTask` r
|
|
|
27
41
|
|
|
28
42
|
A `FetchTask` representing the operation with a `string` response.
|
|
29
43
|
|
|
30
|
-
###
|
|
44
|
+
### Defined in
|
|
31
45
|
|
|
32
|
-
[src/fetch/fetch.ts:14](https://github.com/JiangJie/fetch-t/blob/
|
|
46
|
+
[src/fetch/fetch.ts:14](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L14)
|
|
33
47
|
|
|
34
48
|
## fetchT(url, init)
|
|
35
49
|
|
|
@@ -42,7 +56,7 @@ Fetches a resource from the network as an ArrayBuffer and returns a `FetchTask`
|
|
|
42
56
|
### Parameters
|
|
43
57
|
|
|
44
58
|
| Parameter | Type | Description |
|
|
45
|
-
|
|
|
59
|
+
| ------ | ------ | ------ |
|
|
46
60
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
47
61
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"arraybuffer"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
|
|
48
62
|
|
|
@@ -52,9 +66,9 @@ Fetches a resource from the network as an ArrayBuffer and returns a `FetchTask`
|
|
|
52
66
|
|
|
53
67
|
A `FetchTask` representing the operation with an `ArrayBuffer` response.
|
|
54
68
|
|
|
55
|
-
###
|
|
69
|
+
### Defined in
|
|
56
70
|
|
|
57
|
-
[src/fetch/fetch.ts:26](https://github.com/JiangJie/fetch-t/blob/
|
|
71
|
+
[src/fetch/fetch.ts:26](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L26)
|
|
58
72
|
|
|
59
73
|
## fetchT(url, init)
|
|
60
74
|
|
|
@@ -67,7 +81,7 @@ Fetches a resource from the network as a Blob and returns a `FetchTask` represen
|
|
|
67
81
|
### Parameters
|
|
68
82
|
|
|
69
83
|
| Parameter | Type | Description |
|
|
70
|
-
|
|
|
84
|
+
| ------ | ------ | ------ |
|
|
71
85
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
72
86
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"blob"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
|
|
73
87
|
|
|
@@ -77,9 +91,9 @@ Fetches a resource from the network as a Blob and returns a `FetchTask` represen
|
|
|
77
91
|
|
|
78
92
|
A `FetchTask` representing the operation with a `Blob` response.
|
|
79
93
|
|
|
80
|
-
###
|
|
94
|
+
### Defined in
|
|
81
95
|
|
|
82
|
-
[src/fetch/fetch.ts:38](https://github.com/JiangJie/fetch-t/blob/
|
|
96
|
+
[src/fetch/fetch.ts:38](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L38)
|
|
83
97
|
|
|
84
98
|
## fetchT(url, init)
|
|
85
99
|
|
|
@@ -89,16 +103,16 @@ function fetchT<T>(url, init): FetchTask<T>
|
|
|
89
103
|
|
|
90
104
|
Fetches a resource from the network and parses it as JSON, returning a `FetchTask` representing the operation.
|
|
91
105
|
|
|
92
|
-
### Type
|
|
106
|
+
### Type Parameters
|
|
93
107
|
|
|
94
|
-
| Type
|
|
95
|
-
|
|
|
108
|
+
| Type Parameter | Description |
|
|
109
|
+
| ------ | ------ |
|
|
96
110
|
| `T` | The expected type of the parsed JSON data. |
|
|
97
111
|
|
|
98
112
|
### Parameters
|
|
99
113
|
|
|
100
114
|
| Parameter | Type | Description |
|
|
101
|
-
|
|
|
115
|
+
| ------ | ------ | ------ |
|
|
102
116
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
103
117
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; `responseType`: `"json"`; \} | Additional options for the fetch operation, including custom `FetchInit` properties. |
|
|
104
118
|
|
|
@@ -108,9 +122,9 @@ Fetches a resource from the network and parses it as JSON, returning a `FetchTas
|
|
|
108
122
|
|
|
109
123
|
A `FetchTask` representing the operation with a response parsed as JSON.
|
|
110
124
|
|
|
111
|
-
###
|
|
125
|
+
### Defined in
|
|
112
126
|
|
|
113
|
-
[src/fetch/fetch.ts:51](https://github.com/JiangJie/fetch-t/blob/
|
|
127
|
+
[src/fetch/fetch.ts:51](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L51)
|
|
114
128
|
|
|
115
129
|
## fetchT(url, init)
|
|
116
130
|
|
|
@@ -123,7 +137,7 @@ Fetches a resource from the network as a text string and returns a `FetchRespons
|
|
|
123
137
|
### Parameters
|
|
124
138
|
|
|
125
139
|
| Parameter | Type | Description |
|
|
126
|
-
|
|
|
140
|
+
| ------ | ------ | ------ |
|
|
127
141
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
128
142
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"text"`; \} | Additional options for the fetch operation, specifying the response type as 'text'. |
|
|
129
143
|
|
|
@@ -133,9 +147,9 @@ Fetches a resource from the network as a text string and returns a `FetchRespons
|
|
|
133
147
|
|
|
134
148
|
A `FetchResponse` representing the operation with a `string` response.
|
|
135
149
|
|
|
136
|
-
###
|
|
150
|
+
### Defined in
|
|
137
151
|
|
|
138
|
-
[src/fetch/fetch.ts:63](https://github.com/JiangJie/fetch-t/blob/
|
|
152
|
+
[src/fetch/fetch.ts:63](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L63)
|
|
139
153
|
|
|
140
154
|
## fetchT(url, init)
|
|
141
155
|
|
|
@@ -148,7 +162,7 @@ Fetches a resource from the network as an ArrayBuffer and returns a `FetchRespon
|
|
|
148
162
|
### Parameters
|
|
149
163
|
|
|
150
164
|
| Parameter | Type | Description |
|
|
151
|
-
|
|
|
165
|
+
| ------ | ------ | ------ |
|
|
152
166
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
153
167
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"arraybuffer"`; \} | Additional options for the fetch operation, specifying the response type as 'arraybuffer'. |
|
|
154
168
|
|
|
@@ -158,9 +172,9 @@ Fetches a resource from the network as an ArrayBuffer and returns a `FetchRespon
|
|
|
158
172
|
|
|
159
173
|
A `FetchResponse` representing the operation with an `ArrayBuffer` response.
|
|
160
174
|
|
|
161
|
-
###
|
|
175
|
+
### Defined in
|
|
162
176
|
|
|
163
|
-
[src/fetch/fetch.ts:74](https://github.com/JiangJie/fetch-t/blob/
|
|
177
|
+
[src/fetch/fetch.ts:74](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L74)
|
|
164
178
|
|
|
165
179
|
## fetchT(url, init)
|
|
166
180
|
|
|
@@ -173,7 +187,7 @@ Fetches a resource from the network as a Blob and returns a `FetchResponse` repr
|
|
|
173
187
|
### Parameters
|
|
174
188
|
|
|
175
189
|
| Parameter | Type | Description |
|
|
176
|
-
|
|
|
190
|
+
| ------ | ------ | ------ |
|
|
177
191
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
178
192
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"blob"`; \} | Additional options for the fetch operation, specifying the response type as 'blob'. |
|
|
179
193
|
|
|
@@ -183,9 +197,9 @@ Fetches a resource from the network as a Blob and returns a `FetchResponse` repr
|
|
|
183
197
|
|
|
184
198
|
A `FetchResponse` representing the operation with a `Blob` response.
|
|
185
199
|
|
|
186
|
-
###
|
|
200
|
+
### Defined in
|
|
187
201
|
|
|
188
|
-
[src/fetch/fetch.ts:85](https://github.com/JiangJie/fetch-t/blob/
|
|
202
|
+
[src/fetch/fetch.ts:85](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L85)
|
|
189
203
|
|
|
190
204
|
## fetchT(url, init)
|
|
191
205
|
|
|
@@ -195,16 +209,16 @@ function fetchT<T>(url, init): FetchResponse<T>
|
|
|
195
209
|
|
|
196
210
|
Fetches a resource from the network and parses it as JSON, returning a `FetchResponse` representing the operation.
|
|
197
211
|
|
|
198
|
-
### Type
|
|
212
|
+
### Type Parameters
|
|
199
213
|
|
|
200
|
-
| Type
|
|
201
|
-
|
|
|
214
|
+
| Type Parameter | Description |
|
|
215
|
+
| ------ | ------ |
|
|
202
216
|
| `T` | The expected type of the parsed JSON data. |
|
|
203
217
|
|
|
204
218
|
### Parameters
|
|
205
219
|
|
|
206
220
|
| Parameter | Type | Description |
|
|
207
|
-
|
|
|
221
|
+
| ------ | ------ | ------ |
|
|
208
222
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
209
223
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `responseType`: `"json"`; \} | Additional options for the fetch operation, specifying the response type as 'json'. |
|
|
210
224
|
|
|
@@ -214,9 +228,9 @@ Fetches a resource from the network and parses it as JSON, returning a `FetchRes
|
|
|
214
228
|
|
|
215
229
|
A `FetchResponse` representing the operation with a response parsed as JSON.
|
|
216
230
|
|
|
217
|
-
###
|
|
231
|
+
### Defined in
|
|
218
232
|
|
|
219
|
-
[src/fetch/fetch.ts:97](https://github.com/JiangJie/fetch-t/blob/
|
|
233
|
+
[src/fetch/fetch.ts:97](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L97)
|
|
220
234
|
|
|
221
235
|
## fetchT(url, init)
|
|
222
236
|
|
|
@@ -229,7 +243,7 @@ Fetches a resource from the network and returns a `FetchTask` representing the o
|
|
|
229
243
|
### Parameters
|
|
230
244
|
|
|
231
245
|
| Parameter | Type | Description |
|
|
232
|
-
|
|
|
246
|
+
| ------ | ------ | ------ |
|
|
233
247
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
234
248
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `true`; \} | Additional options for the fetch operation, indicating that the operation should be abortable. |
|
|
235
249
|
|
|
@@ -239,9 +253,9 @@ Fetches a resource from the network and returns a `FetchTask` representing the o
|
|
|
239
253
|
|
|
240
254
|
A `FetchTask` representing the operation with a generic `Response`.
|
|
241
255
|
|
|
242
|
-
###
|
|
256
|
+
### Defined in
|
|
243
257
|
|
|
244
|
-
[src/fetch/fetch.ts:108](https://github.com/JiangJie/fetch-t/blob/
|
|
258
|
+
[src/fetch/fetch.ts:108](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L108)
|
|
245
259
|
|
|
246
260
|
## fetchT(url, init)
|
|
247
261
|
|
|
@@ -254,7 +268,7 @@ Fetches a resource from the network and returns a `FetchResponse` representing t
|
|
|
254
268
|
### Parameters
|
|
255
269
|
|
|
256
270
|
| Parameter | Type | Description |
|
|
257
|
-
|
|
|
271
|
+
| ------ | ------ | ------ |
|
|
258
272
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
259
273
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) & \{ `abortable`: `false`; \} | Additional options for the fetch operation, indicating that the operation should not be abortable. |
|
|
260
274
|
|
|
@@ -264,9 +278,9 @@ Fetches a resource from the network and returns a `FetchResponse` representing t
|
|
|
264
278
|
|
|
265
279
|
A `FetchResponse` representing the operation with a generic `Response`.
|
|
266
280
|
|
|
267
|
-
###
|
|
281
|
+
### Defined in
|
|
268
282
|
|
|
269
|
-
[src/fetch/fetch.ts:119](https://github.com/JiangJie/fetch-t/blob/
|
|
283
|
+
[src/fetch/fetch.ts:119](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L119)
|
|
270
284
|
|
|
271
285
|
## fetchT(url, init)
|
|
272
286
|
|
|
@@ -276,16 +290,16 @@ function fetchT<T>(url, init): FetchTask<T> | FetchResponse<T>
|
|
|
276
290
|
|
|
277
291
|
Fetches a resource from the network and returns a `FetchResponse` or `FetchTask` based on the provided options.
|
|
278
292
|
|
|
279
|
-
### Type
|
|
293
|
+
### Type Parameters
|
|
280
294
|
|
|
281
|
-
| Type
|
|
282
|
-
|
|
|
295
|
+
| Type Parameter | Description |
|
|
296
|
+
| ------ | ------ |
|
|
283
297
|
| `T` | The expected type of the response data when not using a specific `responseType`. |
|
|
284
298
|
|
|
285
299
|
### Parameters
|
|
286
300
|
|
|
287
301
|
| Parameter | Type | Description |
|
|
288
|
-
|
|
|
302
|
+
| ------ | ------ | ------ |
|
|
289
303
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
290
304
|
| `init` | [`FetchInit`](../interfaces/FetchInit.md) | Additional options for the fetch operation, including custom `FetchInit` properties. |
|
|
291
305
|
|
|
@@ -295,9 +309,9 @@ Fetches a resource from the network and returns a `FetchResponse` or `FetchTask`
|
|
|
295
309
|
|
|
296
310
|
A `FetchResponse` or `FetchTask` depending on the `abortable` option in `init`.
|
|
297
311
|
|
|
298
|
-
###
|
|
312
|
+
### Defined in
|
|
299
313
|
|
|
300
|
-
[src/fetch/fetch.ts:131](https://github.com/JiangJie/fetch-t/blob/
|
|
314
|
+
[src/fetch/fetch.ts:131](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L131)
|
|
301
315
|
|
|
302
316
|
## fetchT(url, init)
|
|
303
317
|
|
|
@@ -310,7 +324,7 @@ Fetches a resource from the network and returns a `FetchResponse` representing t
|
|
|
310
324
|
### Parameters
|
|
311
325
|
|
|
312
326
|
| Parameter | Type | Description |
|
|
313
|
-
|
|
|
327
|
+
| ------ | ------ | ------ |
|
|
314
328
|
| `url` | `string` \| `URL` | The resource to fetch. Can be a URL object or a string representing a URL. |
|
|
315
329
|
| `init`? | `RequestInit` | Standard `RequestInit` options for the fetch operation. |
|
|
316
330
|
|
|
@@ -320,6 +334,6 @@ Fetches a resource from the network and returns a `FetchResponse` representing t
|
|
|
320
334
|
|
|
321
335
|
A `FetchResponse` representing the operation with a `Response` object.
|
|
322
336
|
|
|
323
|
-
###
|
|
337
|
+
### Defined in
|
|
324
338
|
|
|
325
|
-
[src/fetch/fetch.ts:140](https://github.com/JiangJie/fetch-t/blob/
|
|
339
|
+
[src/fetch/fetch.ts:140](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/fetch.ts#L140)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
[**@happy-ts/fetch-t**](../
|
|
1
|
+
[**@happy-ts/fetch-t**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@happy-ts/fetch-t](../
|
|
5
|
+
[@happy-ts/fetch-t](../README.md) / FetchInit
|
|
6
6
|
|
|
7
7
|
# Interface: FetchInit
|
|
8
8
|
|
|
@@ -14,21 +14,21 @@ Extends the standard `RequestInit` interface from the Fetch API to include addit
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
| Property | Type | Description | Inherited from |
|
|
18
|
-
|
|
|
19
|
-
| `abortable?` | `boolean` | Indicates whether the fetch request should be abortable. | - |
|
|
20
|
-
| `body?` | `null` \| `BodyInit` | A BodyInit object or null to set request's body. | `RequestInit.body` |
|
|
21
|
-
| `cache?` | `RequestCache` | A string indicating how the request will interact with the browser's cache to set request's cache. | `RequestInit.cache` |
|
|
22
|
-
| `credentials?` | `RequestCredentials` | A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. | `RequestInit.credentials` |
|
|
23
|
-
| `headers?` | `HeadersInit` | A Headers object, an object literal, or an array of two-item arrays to set request's headers. | `RequestInit.headers` |
|
|
24
|
-
| `integrity?` | `string` | A cryptographic hash of the resource to be fetched by request. Sets request's integrity. | `RequestInit.integrity` |
|
|
25
|
-
| `keepalive?` | `boolean` | A boolean to set request's keepalive. | `RequestInit.keepalive` |
|
|
26
|
-
| `method?` | `string` | A string to set request's method. | `RequestInit.method` |
|
|
27
|
-
| `mode?` | `RequestMode` | A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. | `RequestInit.mode` |
|
|
28
|
-
| `priority?` | `RequestPriority` | - | `RequestInit.priority` |
|
|
29
|
-
| `redirect?` | `RequestRedirect` | A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. | `RequestInit.redirect` |
|
|
30
|
-
| `referrer?` | `string` | A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. | `RequestInit.referrer` |
|
|
31
|
-
| `referrerPolicy?` | `ReferrerPolicy` | A referrer policy to set request's referrerPolicy. | `RequestInit.referrerPolicy` |
|
|
32
|
-
| `responseType?` | `"text"` \| `"arraybuffer"` \| `"blob"` \| `"json"` | Specifies the expected response type of the fetch request. | - |
|
|
33
|
-
| `signal?` | `null` \| `AbortSignal` | An AbortSignal to set request's signal. | `RequestInit.signal` |
|
|
34
|
-
| `window?` | `null` | Can only be null. Used to disassociate request from any Window. | `RequestInit.window` |
|
|
17
|
+
| Property | Type | Description | Inherited from | Defined in |
|
|
18
|
+
| ------ | ------ | ------ | ------ | ------ |
|
|
19
|
+
| `abortable?` | `boolean` | Indicates whether the fetch request should be abortable. | - | [src/fetch/defines.ts:42](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/defines.ts#L42) |
|
|
20
|
+
| `body?` | `null` \| `BodyInit` | A BodyInit object or null to set request's body. | `RequestInit.body` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1693 |
|
|
21
|
+
| `cache?` | `RequestCache` | A string indicating how the request will interact with the browser's cache to set request's cache. | `RequestInit.cache` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1695 |
|
|
22
|
+
| `credentials?` | `RequestCredentials` | A string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. Sets request's credentials. | `RequestInit.credentials` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1697 |
|
|
23
|
+
| `headers?` | `HeadersInit` | A Headers object, an object literal, or an array of two-item arrays to set request's headers. | `RequestInit.headers` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1699 |
|
|
24
|
+
| `integrity?` | `string` | A cryptographic hash of the resource to be fetched by request. Sets request's integrity. | `RequestInit.integrity` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1701 |
|
|
25
|
+
| `keepalive?` | `boolean` | A boolean to set request's keepalive. | `RequestInit.keepalive` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1703 |
|
|
26
|
+
| `method?` | `string` | A string to set request's method. | `RequestInit.method` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1705 |
|
|
27
|
+
| `mode?` | `RequestMode` | A string to indicate whether the request will use CORS, or will be restricted to same-origin URLs. Sets request's mode. | `RequestInit.mode` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1707 |
|
|
28
|
+
| `priority?` | `RequestPriority` | - | `RequestInit.priority` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1708 |
|
|
29
|
+
| `redirect?` | `RequestRedirect` | A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. | `RequestInit.redirect` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1710 |
|
|
30
|
+
| `referrer?` | `string` | A string whose value is a same-origin URL, "about:client", or the empty string, to set request's referrer. | `RequestInit.referrer` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1712 |
|
|
31
|
+
| `referrerPolicy?` | `ReferrerPolicy` | A referrer policy to set request's referrerPolicy. | `RequestInit.referrerPolicy` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1714 |
|
|
32
|
+
| `responseType?` | `"text"` \| `"arraybuffer"` \| `"blob"` \| `"json"` | Specifies the expected response type of the fetch request. | - | [src/fetch/defines.ts:47](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/defines.ts#L47) |
|
|
33
|
+
| `signal?` | `null` \| `AbortSignal` | An AbortSignal to set request's signal. | `RequestInit.signal` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1716 |
|
|
34
|
+
| `window?` | `null` | Can only be null. Used to disassociate request from any Window. | `RequestInit.window` | node\_modules/.deno/typescript@5.5.3/node\_modules/typescript/lib/lib.dom.d.ts:1718 |
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
[**@happy-ts/fetch-t**](../
|
|
1
|
+
[**@happy-ts/fetch-t**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@happy-ts/fetch-t](../
|
|
5
|
+
[@happy-ts/fetch-t](../README.md) / FetchTask
|
|
6
6
|
|
|
7
7
|
# Interface: FetchTask\<T\>
|
|
8
8
|
|
|
9
9
|
Defines the structure and behavior of a fetch task, including the ability to abort the task and check its status.
|
|
10
10
|
|
|
11
|
-
## Type
|
|
11
|
+
## Type Parameters
|
|
12
12
|
|
|
13
|
-
| Type
|
|
14
|
-
|
|
|
13
|
+
| Type Parameter | Description |
|
|
14
|
+
| ------ | ------ |
|
|
15
15
|
| `T` | The type of the data expected in the response. |
|
|
16
16
|
|
|
17
17
|
## Properties
|
|
18
18
|
|
|
19
|
-
| Property | Type | Description |
|
|
20
|
-
|
|
|
21
|
-
| `aborted` | `boolean` | Indicates whether the fetch task has been aborted. |
|
|
22
|
-
| `response` | [`FetchResponse`](../type-aliases/FetchResponse.md)\<`T`\> | The response of the fetch task, represented as an `AsyncResult`. |
|
|
19
|
+
| Property | Type | Description | Defined in |
|
|
20
|
+
| ------ | ------ | ------ | ------ |
|
|
21
|
+
| `aborted` | `boolean` | Indicates whether the fetch task has been aborted. | [src/fetch/defines.ts:27](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/defines.ts#L27) |
|
|
22
|
+
| `response` | [`FetchResponse`](../type-aliases/FetchResponse.md)\<`T`\> | The response of the fetch task, represented as an `AsyncResult`. | [src/fetch/defines.ts:32](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/defines.ts#L32) |
|
|
23
23
|
|
|
24
24
|
## Methods
|
|
25
25
|
|
|
@@ -34,13 +34,13 @@ Aborts the fetch task, optionally with a reason for the abortion.
|
|
|
34
34
|
#### Parameters
|
|
35
35
|
|
|
36
36
|
| Parameter | Type | Description |
|
|
37
|
-
|
|
|
37
|
+
| ------ | ------ | ------ |
|
|
38
38
|
| `reason`? | `any` | An optional parameter to indicate why the task was aborted. |
|
|
39
39
|
|
|
40
40
|
#### Returns
|
|
41
41
|
|
|
42
42
|
`void`
|
|
43
43
|
|
|
44
|
-
####
|
|
44
|
+
#### Defined in
|
|
45
45
|
|
|
46
|
-
[src/fetch/defines.ts:22](https://github.com/JiangJie/fetch-t/blob/
|
|
46
|
+
[src/fetch/defines.ts:22](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/defines.ts#L22)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[**@happy-ts/fetch-t**](../
|
|
1
|
+
[**@happy-ts/fetch-t**](../README.md) • **Docs**
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
[@happy-ts/fetch-t](../
|
|
5
|
+
[@happy-ts/fetch-t](../README.md) / FetchResponse
|
|
6
6
|
|
|
7
|
-
# Type
|
|
7
|
+
# Type Alias: FetchResponse\<T\>
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
type FetchResponse<T>: AsyncResult<T, any>;
|
|
@@ -12,12 +12,12 @@ type FetchResponse<T>: AsyncResult<T, any>;
|
|
|
12
12
|
|
|
13
13
|
Represents the response of a fetch operation, encapsulating the result data or any error that occurred.
|
|
14
14
|
|
|
15
|
-
## Type
|
|
15
|
+
## Type Parameters
|
|
16
16
|
|
|
17
|
-
| Type
|
|
18
|
-
|
|
|
17
|
+
| Type Parameter | Description |
|
|
18
|
+
| ------ | ------ |
|
|
19
19
|
| `T` | The type of the data expected in the response. |
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Defined in
|
|
22
22
|
|
|
23
|
-
[src/fetch/defines.ts:9](https://github.com/JiangJie/fetch-t/blob/
|
|
23
|
+
[src/fetch/defines.ts:9](https://github.com/JiangJie/fetch-t/blob/9e5c4ce034f7bf6add07f55044bccbb16a68960c/src/fetch/defines.ts#L9)
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Abortable fetch wrapper with the ability to specify the return type.",
|
|
4
4
|
"author": "jiang115jie@gmail.com",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.10",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"source": "src/mod.ts",
|
|
9
9
|
"main": "dist/main.cjs",
|
|
@@ -43,19 +43,19 @@
|
|
|
43
43
|
"responseType"
|
|
44
44
|
],
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
47
|
-
"@typescript-eslint/parser": "^7.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
47
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
48
48
|
"eslint": "^8.57.0",
|
|
49
|
-
"rollup": "^4.18.
|
|
49
|
+
"rollup": "^4.18.1",
|
|
50
50
|
"rollup-plugin-dts": "^6.1.1",
|
|
51
51
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
52
|
-
"typedoc": "^0.
|
|
53
|
-
"typedoc-plugin-markdown": "^4.
|
|
54
|
-
"typescript": "^5.
|
|
52
|
+
"typedoc": "^0.26.4",
|
|
53
|
+
"typedoc-plugin-markdown": "^4.2.1",
|
|
54
|
+
"typescript": "^5.5.3"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"happy-rusty": "^1.1.
|
|
57
|
+
"happy-rusty": "^1.1.1",
|
|
58
58
|
"tiny-invariant": "^1.3.3"
|
|
59
59
|
},
|
|
60
|
-
"packageManager": "pnpm@9.
|
|
60
|
+
"packageManager": "pnpm@9.5.0"
|
|
61
61
|
}
|