@fuman/fetch 0.0.1 → 0.0.3
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/ffetch.cjs +6 -2
- package/ffetch.js +6 -2
- package/package.json +2 -2
package/ffetch.cjs
CHANGED
|
@@ -62,11 +62,12 @@ class FfetchResultImpl {
|
|
|
62
62
|
return await this.#fetchAndValidate();
|
|
63
63
|
} catch (err_) {
|
|
64
64
|
const err = utils.unknownToError(err_);
|
|
65
|
-
const
|
|
65
|
+
const origMessage = err.message;
|
|
66
|
+
const origStack = err.stack;
|
|
66
67
|
const stack = this.#stack.split("\n").slice(2).join("\n");
|
|
67
68
|
err.stack = `${err.name}: ${err.message}
|
|
68
69
|
${stack}`;
|
|
69
|
-
err.cause =
|
|
70
|
+
err.cause = { message: origMessage, stack: origStack };
|
|
70
71
|
throw err;
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -163,6 +164,9 @@ function createFfetch(baseOptions = {}) {
|
|
|
163
164
|
} else {
|
|
164
165
|
init.body = options.body;
|
|
165
166
|
init.method = options.method ?? baseOptions.method ?? "GET";
|
|
167
|
+
if (init.body instanceof ReadableStream) {
|
|
168
|
+
init.duplex ??= "half";
|
|
169
|
+
}
|
|
166
170
|
}
|
|
167
171
|
init.headers = headers;
|
|
168
172
|
return new FfetchResultInner(fetcher, url, init, headers, options, stack);
|
package/ffetch.js
CHANGED
|
@@ -60,11 +60,12 @@ class FfetchResultImpl {
|
|
|
60
60
|
return await this.#fetchAndValidate();
|
|
61
61
|
} catch (err_) {
|
|
62
62
|
const err = unknownToError(err_);
|
|
63
|
-
const
|
|
63
|
+
const origMessage = err.message;
|
|
64
|
+
const origStack = err.stack;
|
|
64
65
|
const stack = this.#stack.split("\n").slice(2).join("\n");
|
|
65
66
|
err.stack = `${err.name}: ${err.message}
|
|
66
67
|
${stack}`;
|
|
67
|
-
err.cause =
|
|
68
|
+
err.cause = { message: origMessage, stack: origStack };
|
|
68
69
|
throw err;
|
|
69
70
|
}
|
|
70
71
|
}
|
|
@@ -161,6 +162,9 @@ function createFfetch(baseOptions = {}) {
|
|
|
161
162
|
} else {
|
|
162
163
|
init.body = options.body;
|
|
163
164
|
init.method = options.method ?? baseOptions.method ?? "GET";
|
|
165
|
+
if (init.body instanceof ReadableStream) {
|
|
166
|
+
init.duplex ??= "half";
|
|
167
|
+
}
|
|
164
168
|
}
|
|
165
169
|
init.headers = headers;
|
|
166
170
|
return new FfetchResultInner(fetcher, url, init, headers, options, stack);
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuman/fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"description": "tiny wrapper over fetch",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@fuman/utils": "^0.0.
|
|
8
|
+
"@fuman/utils": "^0.0.3"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"tough-cookie": "^5.0.0 || ^4.0.0",
|