@gjsify/fetch 0.3.13 → 0.3.15

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/lib/esm/body.js CHANGED
@@ -1,327 +1,349 @@
1
- import { URLSearchParams } from "@gjsify/url";
2
1
  import { Blob } from "./utils/blob-from.js";
3
- import { PassThrough, pipeline as pipelineCb, Readable, Stream } from "node:stream";
4
- import { Buffer } from "node:buffer";
5
- import { FormData, formDataToBlob } from "@gjsify/formdata";
6
- import { FetchError } from "./errors/fetch-error.js";
7
2
  import { FetchBaseError } from "./errors/base.js";
3
+ import { FetchError } from "./errors/fetch-error.js";
8
4
  import { isBlob, isURLSearchParameters } from "./utils/is.js";
9
- const pipeline = (source, dest) => new Promise((resolve, reject) => {
10
- pipelineCb(source, dest, (err) => {
11
- if (err) reject(err);
12
- else resolve();
13
- });
5
+ import { URLSearchParams } from "@gjsify/url";
6
+ import { Buffer } from "node:buffer";
7
+ import { PassThrough, Readable, Stream as Stream$1, pipeline } from "node:stream";
8
+ import { FormData, formDataToBlob } from "@gjsify/formdata";
9
+
10
+ //#region src/body.ts
11
+ const pipeline$1 = (source, dest) => new Promise((resolve, reject) => {
12
+ pipeline(source, dest, (err) => {
13
+ if (err) reject(err);
14
+ else resolve();
15
+ });
14
16
  });
15
- const INTERNALS = /* @__PURE__ */ Symbol("Body internals");
17
+ const INTERNALS = Symbol("Body internals");
16
18
  function isAnyArrayBuffer(val) {
17
- return val instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && val instanceof SharedArrayBuffer;
19
+ return val instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && val instanceof SharedArrayBuffer;
18
20
  }
19
21
  function isBoxedPrimitive(val) {
20
- return val instanceof String || val instanceof Number || val instanceof Boolean || typeof Symbol !== "undefined" && val instanceof Symbol || typeof BigInt !== "undefined" && val instanceof BigInt;
21
- }
22
- class Body {
23
- [INTERNALS] = {
24
- body: null,
25
- stream: null,
26
- boundary: "",
27
- disturbed: false,
28
- error: null
29
- };
30
- size = 0;
31
- constructor(body, options = { size: 0 }) {
32
- this.size = options.size || 0;
33
- if (body === null || body === void 0) {
34
- this[INTERNALS].body = null;
35
- } else if (isURLSearchParameters(body)) {
36
- this[INTERNALS].body = Buffer.from(body.toString());
37
- } else if (isBlob(body)) {
38
- this[INTERNALS].body = body;
39
- } else if (Buffer.isBuffer(body)) {
40
- this[INTERNALS].body = body;
41
- } else if (isAnyArrayBuffer(body)) {
42
- this[INTERNALS].body = Buffer.from(body);
43
- } else if (ArrayBuffer.isView(body)) {
44
- this[INTERNALS].body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
45
- } else if (body instanceof Readable) {
46
- this[INTERNALS].body = body;
47
- } else if (typeof ReadableStream !== "undefined" && body instanceof ReadableStream) {
48
- this[INTERNALS].body = readableStreamToReadable(body);
49
- } else if (body instanceof FormData) {
50
- const blob = formDataToBlob(body);
51
- this[INTERNALS].body = blob;
52
- this[INTERNALS].boundary = blob.type?.split("boundary=")?.[1] ?? "";
53
- } else if (typeof body === "string") {
54
- this[INTERNALS].body = Buffer.from(body);
55
- } else if (body instanceof URLSearchParams) {
56
- this[INTERNALS].body = Buffer.from(body.toString());
57
- } else {
58
- console.warn(`Unknown body type "${typeof body}", try to parse the body to string!`);
59
- this[INTERNALS].body = Buffer.from(String(body));
60
- }
61
- const b = this[INTERNALS].body;
62
- if (Buffer.isBuffer(b)) {
63
- this[INTERNALS].stream = Readable.from(b);
64
- } else if (isBlob(b)) {
65
- this[INTERNALS].stream = Readable.from(blobToAsyncIterable(b));
66
- } else if (b instanceof Readable) {
67
- this[INTERNALS].stream = b;
68
- }
69
- if (b instanceof Stream) {
70
- b.on("error", (error_) => {
71
- const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
72
- this[INTERNALS].error = error;
73
- });
74
- }
75
- }
76
- get body() {
77
- const stream = this[INTERNALS].stream;
78
- if (!stream) return null;
79
- if (typeof ReadableStream !== "undefined") {
80
- let closed = false;
81
- return new ReadableStream({
82
- start(controller) {
83
- stream.on("data", (chunk) => {
84
- if (closed) return;
85
- try {
86
- controller.enqueue(chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk));
87
- } catch {
88
- }
89
- });
90
- stream.on("end", () => {
91
- if (closed) return;
92
- closed = true;
93
- try {
94
- controller.close();
95
- } catch {
96
- }
97
- });
98
- stream.on("error", (err) => {
99
- if (closed) return;
100
- closed = true;
101
- try {
102
- controller.error(err);
103
- } catch {
104
- }
105
- });
106
- },
107
- cancel() {
108
- closed = true;
109
- stream.destroy();
110
- }
111
- });
112
- }
113
- return null;
114
- }
115
- get _stream() {
116
- return this[INTERNALS].stream;
117
- }
118
- /** Return the raw body buffer without consuming the stream (used by Request._send). */
119
- get _rawBodyBuffer() {
120
- const b = this[INTERNALS].body;
121
- if (b === null) return null;
122
- if (Buffer.isBuffer(b)) return b;
123
- if (b instanceof Uint8Array) return Buffer.from(b.buffer, b.byteOffset, b.byteLength);
124
- return null;
125
- }
126
- get bodyUsed() {
127
- return this[INTERNALS].disturbed;
128
- }
129
- /**
130
- * Decode response as ArrayBuffer
131
- */
132
- async arrayBuffer() {
133
- const { buffer, byteOffset, byteLength } = await consumeBody(this);
134
- return buffer.slice(byteOffset, byteOffset + byteLength);
135
- }
136
- async formData() {
137
- const ct = this.headers?.get("content-type");
138
- if (ct?.startsWith("application/x-www-form-urlencoded")) {
139
- const formData = new FormData();
140
- const parameters = new URLSearchParams(await this.text());
141
- for (const [name, value] of parameters) {
142
- formData.append(name, value);
143
- }
144
- return formData;
145
- }
146
- const { toFormData } = await import("./utils/multipart-parser.js");
147
- return toFormData(this.body, ct);
148
- }
149
- /**
150
- * Return raw response as Blob
151
- */
152
- async blob() {
153
- const ct = this.headers?.get("content-type") || this[INTERNALS].body && this[INTERNALS].body.type || "";
154
- const buf = await this.arrayBuffer();
155
- return new Blob([buf], {
156
- type: ct
157
- });
158
- }
159
- /**
160
- * Decode response as json
161
- */
162
- async json() {
163
- const text = await this.text();
164
- return JSON.parse(text);
165
- }
166
- /**
167
- * Decode response as text
168
- */
169
- async text() {
170
- const buffer = await consumeBody(this);
171
- return new TextDecoder().decode(buffer);
172
- }
22
+ return val instanceof String || val instanceof Number || val instanceof Boolean || typeof Symbol !== "undefined" && val instanceof Symbol || typeof BigInt !== "undefined" && val instanceof BigInt;
173
23
  }
24
+ /**
25
+ * Body mixin
26
+ *
27
+ * Ref: https://fetch.spec.whatwg.org/#body
28
+ *
29
+ * @param body Readable stream
30
+ * @param opts Response options
31
+ */
32
+ var Body = class {
33
+ [INTERNALS] = {
34
+ body: null,
35
+ stream: null,
36
+ boundary: "",
37
+ disturbed: false,
38
+ error: null
39
+ };
40
+ size = 0;
41
+ constructor(body, options = { size: 0 }) {
42
+ this.size = options.size || 0;
43
+ if (body === null || body === undefined) {
44
+ this[INTERNALS].body = null;
45
+ } else if (isURLSearchParameters(body)) {
46
+ this[INTERNALS].body = Buffer.from(body.toString());
47
+ } else if (isBlob(body)) {
48
+ this[INTERNALS].body = body;
49
+ } else if (Buffer.isBuffer(body)) {
50
+ this[INTERNALS].body = body;
51
+ } else if (isAnyArrayBuffer(body)) {
52
+ this[INTERNALS].body = Buffer.from(body);
53
+ } else if (ArrayBuffer.isView(body)) {
54
+ this[INTERNALS].body = Buffer.from(body.buffer, body.byteOffset, body.byteLength);
55
+ } else if (body instanceof Readable) {
56
+ this[INTERNALS].body = body;
57
+ } else if (typeof ReadableStream !== "undefined" && body instanceof ReadableStream) {
58
+ this[INTERNALS].body = readableStreamToReadable(body);
59
+ } else if (body instanceof FormData) {
60
+ const blob = formDataToBlob(body);
61
+ this[INTERNALS].body = blob;
62
+ this[INTERNALS].boundary = blob.type?.split("boundary=")?.[1] ?? "";
63
+ } else if (typeof body === "string") {
64
+ this[INTERNALS].body = Buffer.from(body);
65
+ } else if (body instanceof URLSearchParams) {
66
+ this[INTERNALS].body = Buffer.from(body.toString());
67
+ } else {
68
+ console.warn(`Unknown body type "${typeof body}", try to parse the body to string!`);
69
+ this[INTERNALS].body = Buffer.from(String(body));
70
+ }
71
+ const b = this[INTERNALS].body;
72
+ if (Buffer.isBuffer(b)) {
73
+ this[INTERNALS].stream = Readable.from(b);
74
+ } else if (isBlob(b)) {
75
+ this[INTERNALS].stream = Readable.from(blobToAsyncIterable(b));
76
+ } else if (b instanceof Readable) {
77
+ this[INTERNALS].stream = b;
78
+ }
79
+ if (b instanceof Stream$1) {
80
+ b.on("error", (error_) => {
81
+ const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
82
+ this[INTERNALS].error = error;
83
+ });
84
+ }
85
+ }
86
+ get body() {
87
+ const stream = this[INTERNALS].stream;
88
+ if (!stream) return null;
89
+ if (typeof ReadableStream !== "undefined") {
90
+ let closed = false;
91
+ return new ReadableStream({
92
+ start(controller) {
93
+ stream.on("data", (chunk) => {
94
+ if (closed) return;
95
+ try {
96
+ controller.enqueue(chunk instanceof Uint8Array ? chunk : new Uint8Array(chunk));
97
+ } catch {}
98
+ });
99
+ stream.on("end", () => {
100
+ if (closed) return;
101
+ closed = true;
102
+ try {
103
+ controller.close();
104
+ } catch {}
105
+ });
106
+ stream.on("error", (err) => {
107
+ if (closed) return;
108
+ closed = true;
109
+ try {
110
+ controller.error(err);
111
+ } catch {}
112
+ });
113
+ },
114
+ cancel() {
115
+ closed = true;
116
+ stream.destroy();
117
+ }
118
+ });
119
+ }
120
+ return null;
121
+ }
122
+ get _stream() {
123
+ return this[INTERNALS].stream;
124
+ }
125
+ /** Return the raw body buffer without consuming the stream (used by Request._send). */
126
+ get _rawBodyBuffer() {
127
+ const b = this[INTERNALS].body;
128
+ if (b === null) return null;
129
+ if (Buffer.isBuffer(b)) return b;
130
+ if (b instanceof Uint8Array) return Buffer.from(b.buffer, b.byteOffset, b.byteLength);
131
+ return null;
132
+ }
133
+ get bodyUsed() {
134
+ return this[INTERNALS].disturbed;
135
+ }
136
+ /**
137
+ * Decode response as ArrayBuffer
138
+ */
139
+ async arrayBuffer() {
140
+ const { buffer, byteOffset, byteLength } = await consumeBody(this);
141
+ return buffer.slice(byteOffset, byteOffset + byteLength);
142
+ }
143
+ async formData() {
144
+ const ct = this.headers?.get("content-type");
145
+ if (ct?.startsWith("application/x-www-form-urlencoded")) {
146
+ const formData = new FormData();
147
+ const parameters = new URLSearchParams(await this.text());
148
+ for (const [name, value] of parameters) {
149
+ formData.append(name, value);
150
+ }
151
+ return formData;
152
+ }
153
+ const { toFormData } = await import("./utils/multipart-parser.js");
154
+ return toFormData(this.body, ct);
155
+ }
156
+ /**
157
+ * Return raw response as Blob
158
+ */
159
+ async blob() {
160
+ const ct = this.headers?.get("content-type") || this[INTERNALS].body && this[INTERNALS].body.type || "";
161
+ const buf = await this.arrayBuffer();
162
+ return new Blob([buf], { type: ct });
163
+ }
164
+ /**
165
+ * Decode response as json
166
+ */
167
+ async json() {
168
+ const text = await this.text();
169
+ return JSON.parse(text);
170
+ }
171
+ /**
172
+ * Decode response as text
173
+ */
174
+ async text() {
175
+ const buffer = await consumeBody(this);
176
+ return new TextDecoder().decode(buffer);
177
+ }
178
+ };
174
179
  Object.defineProperties(Body.prototype, {
175
- body: { enumerable: true },
176
- bodyUsed: { enumerable: true },
177
- arrayBuffer: { enumerable: true },
178
- blob: { enumerable: true },
179
- json: { enumerable: true },
180
- text: { enumerable: true }
180
+ body: { enumerable: true },
181
+ bodyUsed: { enumerable: true },
182
+ arrayBuffer: { enumerable: true },
183
+ blob: { enumerable: true },
184
+ json: { enumerable: true },
185
+ text: { enumerable: true }
181
186
  });
187
+ /**
188
+ * Consume and convert an entire Body to a Buffer.
189
+ */
182
190
  async function consumeBody(data) {
183
- if (data[INTERNALS].disturbed) {
184
- throw new TypeError(`body used already for: ${data.url}`);
185
- }
186
- data[INTERNALS].disturbed = true;
187
- if (data[INTERNALS].error) {
188
- throw data[INTERNALS].error;
189
- }
190
- const { _stream: body } = data;
191
- if (body === null) {
192
- return Buffer.alloc(0);
193
- }
194
- if (!(body instanceof Stream)) {
195
- return Buffer.alloc(0);
196
- }
197
- const accum = [];
198
- let accumBytes = 0;
199
- try {
200
- for await (const chunk of body) {
201
- if (data.size > 0 && accumBytes + chunk.length > data.size) {
202
- const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
203
- body.destroy(error);
204
- throw error;
205
- }
206
- accumBytes += chunk.length;
207
- accum.push(chunk);
208
- }
209
- } catch (error) {
210
- const err = error instanceof Error ? error : new Error(String(error));
211
- const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${err.message}`, "system", err);
212
- throw error_;
213
- }
214
- try {
215
- if (accum.every((c) => typeof c === "string")) {
216
- return Buffer.from(accum.join(""));
217
- }
218
- return Buffer.concat(accum, accumBytes);
219
- } catch (error) {
220
- const err = error instanceof Error ? error : new Error(String(error));
221
- throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${err.message}`, "system", err);
222
- }
191
+ if (data[INTERNALS].disturbed) {
192
+ throw new TypeError(`body used already for: ${data.url}`);
193
+ }
194
+ data[INTERNALS].disturbed = true;
195
+ if (data[INTERNALS].error) {
196
+ throw data[INTERNALS].error;
197
+ }
198
+ const { _stream: body } = data;
199
+ if (body === null) {
200
+ return Buffer.alloc(0);
201
+ }
202
+ if (!(body instanceof Stream$1)) {
203
+ return Buffer.alloc(0);
204
+ }
205
+ const accum = [];
206
+ let accumBytes = 0;
207
+ try {
208
+ for await (const chunk of body) {
209
+ if (data.size > 0 && accumBytes + chunk.length > data.size) {
210
+ const error = new FetchError(`content size at ${data.url} over limit: ${data.size}`, "max-size");
211
+ body.destroy(error);
212
+ throw error;
213
+ }
214
+ accumBytes += chunk.length;
215
+ accum.push(chunk);
216
+ }
217
+ } catch (error) {
218
+ const err = error instanceof Error ? error : new Error(String(error));
219
+ const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data.url}: ${err.message}`, "system", err);
220
+ throw error_;
221
+ }
222
+ try {
223
+ if (accum.every((c) => typeof c === "string")) {
224
+ return Buffer.from(accum.join(""));
225
+ }
226
+ return Buffer.concat(accum, accumBytes);
227
+ } catch (error) {
228
+ const err = error instanceof Error ? error : new Error(String(error));
229
+ throw new FetchError(`Could not create Buffer from response body for ${data.url}: ${err.message}`, "system", err);
230
+ }
223
231
  }
232
+ /**
233
+ * Clone body given Res/Req instance
234
+ */
224
235
  const clone = (instance, highWaterMark) => {
225
- let p1;
226
- let p2;
227
- let { body } = instance[INTERNALS];
228
- if (instance.bodyUsed) {
229
- throw new Error("cannot clone body after it is used");
230
- }
231
- if (body instanceof Stream && typeof body.getBoundary !== "function") {
232
- p1 = new PassThrough({ highWaterMark });
233
- p2 = new PassThrough({ highWaterMark });
234
- body.pipe(p1);
235
- body.pipe(p2);
236
- instance[INTERNALS].stream = p1;
237
- body = p2;
238
- }
239
- return body;
236
+ let p1;
237
+ let p2;
238
+ let { body } = instance[INTERNALS];
239
+ if (instance.bodyUsed) {
240
+ throw new Error("cannot clone body after it is used");
241
+ }
242
+ if (body instanceof Stream$1 && typeof body.getBoundary !== "function") {
243
+ p1 = new PassThrough({ highWaterMark });
244
+ p2 = new PassThrough({ highWaterMark });
245
+ body.pipe(p1);
246
+ body.pipe(p2);
247
+ instance[INTERNALS].stream = p1;
248
+ body = p2;
249
+ }
250
+ return body;
240
251
  };
252
+ /**
253
+ * Extract a Content-Type value from a body.
254
+ */
241
255
  const extractContentType = (body, request) => {
242
- if (body === null) {
243
- return null;
244
- }
245
- if (typeof body === "string") {
246
- return "text/plain;charset=UTF-8";
247
- }
248
- if (isURLSearchParameters(body)) {
249
- return "application/x-www-form-urlencoded;charset=UTF-8";
250
- }
251
- if (isBlob(body)) {
252
- return body.type || null;
253
- }
254
- if (Buffer.isBuffer(body) || isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
255
- return null;
256
- }
257
- if (body instanceof FormData) {
258
- return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
259
- }
260
- if (body instanceof Stream) {
261
- return null;
262
- }
263
- return "text/plain;charset=UTF-8";
256
+ if (body === null) {
257
+ return null;
258
+ }
259
+ if (typeof body === "string") {
260
+ return "text/plain;charset=UTF-8";
261
+ }
262
+ if (isURLSearchParameters(body)) {
263
+ return "application/x-www-form-urlencoded;charset=UTF-8";
264
+ }
265
+ if (isBlob(body)) {
266
+ return body.type || null;
267
+ }
268
+ if (Buffer.isBuffer(body) || isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
269
+ return null;
270
+ }
271
+ if (body instanceof FormData) {
272
+ return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
273
+ }
274
+ if (body instanceof Stream$1) {
275
+ return null;
276
+ }
277
+ return "text/plain;charset=UTF-8";
264
278
  };
279
+ /**
280
+ * Get total bytes of a body.
281
+ */
265
282
  const getTotalBytes = (request) => {
266
- const { body } = request[INTERNALS];
267
- if (body === null) {
268
- return 0;
269
- }
270
- if (isBlob(body)) {
271
- return body.size;
272
- }
273
- if (Buffer.isBuffer(body)) {
274
- return body.length;
275
- }
276
- if (body && typeof body.getLengthSync === "function") {
277
- const streamBody = body;
278
- return streamBody.hasKnownLength && streamBody.hasKnownLength() ? streamBody.getLengthSync() : null;
279
- }
280
- return null;
283
+ const { body } = request[INTERNALS];
284
+ if (body === null) {
285
+ return 0;
286
+ }
287
+ if (isBlob(body)) {
288
+ return body.size;
289
+ }
290
+ if (Buffer.isBuffer(body)) {
291
+ return body.length;
292
+ }
293
+ if (body && typeof body.getLengthSync === "function") {
294
+ const streamBody = body;
295
+ return streamBody.hasKnownLength && streamBody.hasKnownLength() ? streamBody.getLengthSync() : null;
296
+ }
297
+ return null;
281
298
  };
299
+ /**
300
+ * Write a Body to a Node.js WritableStream.
301
+ */
282
302
  const writeToStream = async (dest, { body }) => {
283
- if (body === null) {
284
- dest.end();
285
- } else {
286
- await pipeline(body, dest);
287
- }
303
+ if (body === null) {
304
+ dest.end();
305
+ } else {
306
+ await pipeline$1(body, dest);
307
+ }
288
308
  };
309
+ /**
310
+ * Convert a Web ReadableStream to a Node.js Readable.
311
+ */
289
312
  function readableStreamToReadable(webStream) {
290
- const reader = webStream.getReader();
291
- return new Readable({
292
- async read() {
293
- try {
294
- const { done, value } = await reader.read();
295
- if (done) {
296
- this.push(null);
297
- } else {
298
- this.push(Buffer.from(value));
299
- }
300
- } catch (err) {
301
- this.destroy(err);
302
- }
303
- },
304
- destroy(_err, callback) {
305
- reader.cancel().then(() => callback(null), callback);
306
- }
307
- });
313
+ const reader = webStream.getReader();
314
+ return new Readable({
315
+ async read() {
316
+ try {
317
+ const { done, value } = await reader.read();
318
+ if (done) {
319
+ this.push(null);
320
+ } else {
321
+ this.push(Buffer.from(value));
322
+ }
323
+ } catch (err) {
324
+ this.destroy(err);
325
+ }
326
+ },
327
+ destroy(_err, callback) {
328
+ reader.cancel().then(() => callback(null), callback);
329
+ }
330
+ });
308
331
  }
332
+ /**
333
+ * Convert a Blob to an async iterable for Readable.from().
334
+ */
309
335
  async function* blobToAsyncIterable(blob) {
310
- if (typeof blob.stream === "function") {
311
- const reader = blob.stream().getReader();
312
- while (true) {
313
- const { done, value } = await reader.read();
314
- if (done) break;
315
- yield value;
316
- }
317
- } else {
318
- yield new Uint8Array(await blob.arrayBuffer());
319
- }
336
+ if (typeof blob.stream === "function") {
337
+ const reader = blob.stream().getReader();
338
+ while (true) {
339
+ const { done, value } = await reader.read();
340
+ if (done) break;
341
+ yield value;
342
+ }
343
+ } else {
344
+ yield new Uint8Array(await blob.arrayBuffer());
345
+ }
320
346
  }
321
- export {
322
- clone,
323
- Body as default,
324
- extractContentType,
325
- getTotalBytes,
326
- writeToStream
327
- };
347
+
348
+ //#endregion
349
+ export { clone, Body as default, extractContentType, getTotalBytes, writeToStream };
@@ -1,9 +1,14 @@
1
1
  import { FetchBaseError } from "./base.js";
2
- class AbortError extends FetchBaseError {
3
- constructor(message, type = "aborted") {
4
- super(message, type);
5
- }
6
- }
7
- export {
8
- AbortError
2
+
3
+ //#region src/errors/abort-error.ts
4
+ /**
5
+ * AbortError interface for cancelled requests
6
+ */
7
+ var AbortError = class extends FetchBaseError {
8
+ constructor(message, type = "aborted") {
9
+ super(message, type);
10
+ }
9
11
  };
12
+
13
+ //#endregion
14
+ export { AbortError };