@modern-js/create-request 2.27.0 → 2.28.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/dist/cjs/browser.js +2 -2
- package/dist/cjs/handleRes.js +5 -4
- package/dist/cjs/node.js +2 -2
- package/dist/esm/browser.js +2 -2
- package/dist/esm/handleRes.js +5 -5
- package/dist/esm/node.js +2 -2
- package/dist/esm-node/browser.js +2 -2
- package/dist/esm-node/handleRes.js +5 -4
- package/dist/esm-node/node.js +2 -2
- package/package.json +5 -5
package/dist/cjs/browser.js
CHANGED
|
@@ -23,9 +23,9 @@ const _handleRes = require("./handleRes");
|
|
|
23
23
|
let realRequest;
|
|
24
24
|
let realAllowedHeaders;
|
|
25
25
|
const originFetch = (...params) => {
|
|
26
|
-
var _init_method;
|
|
26
|
+
var _init_method, _init;
|
|
27
27
|
const [url, init] = params;
|
|
28
|
-
if ((init === null ||
|
|
28
|
+
if (((_init = init) === null || _init === void 0 ? void 0 : (_init_method = _init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
|
|
29
29
|
init.body = void 0;
|
|
30
30
|
}
|
|
31
31
|
return fetch(url, init).then(_handleRes.handleRes);
|
package/dist/cjs/handleRes.js
CHANGED
|
@@ -9,22 +9,23 @@ Object.defineProperty(exports, "handleRes", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const handleRes = async (res) => {
|
|
12
|
+
var _contentType, _contentType1, _contentType2, _contentType3, _contentType4, _contentType5, _contentType6;
|
|
12
13
|
const contentType = res.headers.get("content-type");
|
|
13
14
|
if (!res.ok) {
|
|
14
15
|
const data = await res.json();
|
|
15
16
|
res.data = data;
|
|
16
17
|
throw res;
|
|
17
18
|
}
|
|
18
|
-
if ((contentType === null ||
|
|
19
|
+
if (((_contentType = contentType) === null || _contentType === void 0 ? void 0 : _contentType.includes("application/json")) || ((_contentType1 = contentType) === null || _contentType1 === void 0 ? void 0 : _contentType1.includes("text/json"))) {
|
|
19
20
|
return res.json();
|
|
20
21
|
}
|
|
21
|
-
if ((contentType === null ||
|
|
22
|
+
if (((_contentType2 = contentType) === null || _contentType2 === void 0 ? void 0 : _contentType2.includes("text/html")) || ((_contentType3 = contentType) === null || _contentType3 === void 0 ? void 0 : _contentType3.includes("text/plain"))) {
|
|
22
23
|
return res.text();
|
|
23
24
|
}
|
|
24
|
-
if (((contentType === null ||
|
|
25
|
+
if ((((_contentType4 = contentType) === null || _contentType4 === void 0 ? void 0 : _contentType4.includes("application/x-www-form-urlencoded")) || ((_contentType5 = contentType) === null || _contentType5 === void 0 ? void 0 : _contentType5.includes("multipart/form-data"))) && res instanceof Response) {
|
|
25
26
|
return res.formData();
|
|
26
27
|
}
|
|
27
|
-
if (contentType === null ||
|
|
28
|
+
if ((_contentType6 = contentType) === null || _contentType6 === void 0 ? void 0 : _contentType6.includes("application/octet-stream")) {
|
|
28
29
|
return res.arrayBuffer();
|
|
29
30
|
}
|
|
30
31
|
return res.text();
|
package/dist/cjs/node.js
CHANGED
|
@@ -26,9 +26,9 @@ const _handleRes = require("./handleRes");
|
|
|
26
26
|
let realRequest;
|
|
27
27
|
let realAllowedHeaders = [];
|
|
28
28
|
const originFetch = (...params) => {
|
|
29
|
-
var _init_method;
|
|
29
|
+
var _init_method, _init;
|
|
30
30
|
const [, init] = params;
|
|
31
|
-
if ((init === null ||
|
|
31
|
+
if (((_init = init) === null || _init === void 0 ? void 0 : (_init_method = _init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
|
|
32
32
|
init.body = void 0;
|
|
33
33
|
}
|
|
34
34
|
return (0, _nodefetch.default)(...params).then(_handleRes.handleRes);
|
package/dist/esm/browser.js
CHANGED
|
@@ -11,9 +11,9 @@ var originFetch = function() {
|
|
|
11
11
|
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
12
|
params[_key] = arguments[_key];
|
|
13
13
|
}
|
|
14
|
-
var _init_method;
|
|
14
|
+
var _init_method, _init;
|
|
15
15
|
var _params = _sliced_to_array(params, 2), url = _params[0], init = _params[1];
|
|
16
|
-
if ((init === null ||
|
|
16
|
+
if (((_init = init) === null || _init === void 0 ? void 0 : (_init_method = _init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
|
|
17
17
|
init.body = void 0;
|
|
18
18
|
}
|
|
19
19
|
return fetch(url, init).then(handleRes);
|
package/dist/esm/handleRes.js
CHANGED
|
@@ -3,7 +3,7 @@ import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
|
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
4
|
var handleRes = function() {
|
|
5
5
|
var _ref = _async_to_generator(function(res) {
|
|
6
|
-
var contentType, data;
|
|
6
|
+
var _contentType, _contentType1, _contentType2, _contentType3, _contentType4, _contentType5, _contentType6, contentType, data;
|
|
7
7
|
return _ts_generator(this, function(_state) {
|
|
8
8
|
switch (_state.label) {
|
|
9
9
|
case 0:
|
|
@@ -22,25 +22,25 @@ var handleRes = function() {
|
|
|
22
22
|
res.data = data;
|
|
23
23
|
throw res;
|
|
24
24
|
case 2:
|
|
25
|
-
if ((contentType === null ||
|
|
25
|
+
if (((_contentType = contentType) === null || _contentType === void 0 ? void 0 : _contentType.includes("application/json")) || ((_contentType1 = contentType) === null || _contentType1 === void 0 ? void 0 : _contentType1.includes("text/json"))) {
|
|
26
26
|
return [
|
|
27
27
|
2,
|
|
28
28
|
res.json()
|
|
29
29
|
];
|
|
30
30
|
}
|
|
31
|
-
if ((contentType === null ||
|
|
31
|
+
if (((_contentType2 = contentType) === null || _contentType2 === void 0 ? void 0 : _contentType2.includes("text/html")) || ((_contentType3 = contentType) === null || _contentType3 === void 0 ? void 0 : _contentType3.includes("text/plain"))) {
|
|
32
32
|
return [
|
|
33
33
|
2,
|
|
34
34
|
res.text()
|
|
35
35
|
];
|
|
36
36
|
}
|
|
37
|
-
if (((contentType === null ||
|
|
37
|
+
if ((((_contentType4 = contentType) === null || _contentType4 === void 0 ? void 0 : _contentType4.includes("application/x-www-form-urlencoded")) || ((_contentType5 = contentType) === null || _contentType5 === void 0 ? void 0 : _contentType5.includes("multipart/form-data"))) && _instanceof(res, Response)) {
|
|
38
38
|
return [
|
|
39
39
|
2,
|
|
40
40
|
res.formData()
|
|
41
41
|
];
|
|
42
42
|
}
|
|
43
|
-
if (contentType === null ||
|
|
43
|
+
if ((_contentType6 = contentType) === null || _contentType6 === void 0 ? void 0 : _contentType6.includes("application/octet-stream")) {
|
|
44
44
|
return [
|
|
45
45
|
2,
|
|
46
46
|
res.arrayBuffer()
|
package/dist/esm/node.js
CHANGED
|
@@ -11,9 +11,9 @@ var originFetch = function() {
|
|
|
11
11
|
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
12
|
params[_key] = arguments[_key];
|
|
13
13
|
}
|
|
14
|
-
var _init_method;
|
|
14
|
+
var _init_method, _init;
|
|
15
15
|
var _params = _sliced_to_array(params, 2), init = _params[1];
|
|
16
|
-
if ((init === null ||
|
|
16
|
+
if (((_init = init) === null || _init === void 0 ? void 0 : (_init_method = _init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
|
|
17
17
|
init.body = void 0;
|
|
18
18
|
}
|
|
19
19
|
return nodeFetch.apply(void 0, _to_consumable_array(params)).then(handleRes);
|
package/dist/esm-node/browser.js
CHANGED
|
@@ -4,9 +4,9 @@ import { handleRes } from "./handleRes";
|
|
|
4
4
|
let realRequest;
|
|
5
5
|
let realAllowedHeaders;
|
|
6
6
|
const originFetch = (...params) => {
|
|
7
|
-
var _init_method;
|
|
7
|
+
var _init_method, _init;
|
|
8
8
|
const [url, init] = params;
|
|
9
|
-
if ((init === null ||
|
|
9
|
+
if (((_init = init) === null || _init === void 0 ? void 0 : (_init_method = _init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
|
|
10
10
|
init.body = void 0;
|
|
11
11
|
}
|
|
12
12
|
return fetch(url, init).then(handleRes);
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
const handleRes = async (res) => {
|
|
2
|
+
var _contentType, _contentType1, _contentType2, _contentType3, _contentType4, _contentType5, _contentType6;
|
|
2
3
|
const contentType = res.headers.get("content-type");
|
|
3
4
|
if (!res.ok) {
|
|
4
5
|
const data = await res.json();
|
|
5
6
|
res.data = data;
|
|
6
7
|
throw res;
|
|
7
8
|
}
|
|
8
|
-
if ((contentType === null ||
|
|
9
|
+
if (((_contentType = contentType) === null || _contentType === void 0 ? void 0 : _contentType.includes("application/json")) || ((_contentType1 = contentType) === null || _contentType1 === void 0 ? void 0 : _contentType1.includes("text/json"))) {
|
|
9
10
|
return res.json();
|
|
10
11
|
}
|
|
11
|
-
if ((contentType === null ||
|
|
12
|
+
if (((_contentType2 = contentType) === null || _contentType2 === void 0 ? void 0 : _contentType2.includes("text/html")) || ((_contentType3 = contentType) === null || _contentType3 === void 0 ? void 0 : _contentType3.includes("text/plain"))) {
|
|
12
13
|
return res.text();
|
|
13
14
|
}
|
|
14
|
-
if (((contentType === null ||
|
|
15
|
+
if ((((_contentType4 = contentType) === null || _contentType4 === void 0 ? void 0 : _contentType4.includes("application/x-www-form-urlencoded")) || ((_contentType5 = contentType) === null || _contentType5 === void 0 ? void 0 : _contentType5.includes("multipart/form-data"))) && res instanceof Response) {
|
|
15
16
|
return res.formData();
|
|
16
17
|
}
|
|
17
|
-
if (contentType === null ||
|
|
18
|
+
if ((_contentType6 = contentType) === null || _contentType6 === void 0 ? void 0 : _contentType6.includes("application/octet-stream")) {
|
|
18
19
|
return res.arrayBuffer();
|
|
19
20
|
}
|
|
20
21
|
return res.text();
|
package/dist/esm-node/node.js
CHANGED
|
@@ -6,9 +6,9 @@ import { handleRes } from "./handleRes";
|
|
|
6
6
|
let realRequest;
|
|
7
7
|
let realAllowedHeaders = [];
|
|
8
8
|
const originFetch = (...params) => {
|
|
9
|
-
var _init_method;
|
|
9
|
+
var _init_method, _init;
|
|
10
10
|
const [, init] = params;
|
|
11
|
-
if ((init === null ||
|
|
11
|
+
if (((_init = init) === null || _init === void 0 ? void 0 : (_init_method = _init.method) === null || _init_method === void 0 ? void 0 : _init_method.toLowerCase()) === "get") {
|
|
12
12
|
init.body = void 0;
|
|
13
13
|
}
|
|
14
14
|
return nodeFetch(...params).then(handleRes);
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.28.0",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"path-to-regexp": "^6.2.0",
|
|
65
65
|
"query-string": "^7.1.1",
|
|
66
66
|
"@swc/helpers": "0.5.1",
|
|
67
|
-
"@modern-js/utils": "2.
|
|
67
|
+
"@modern-js/utils": "2.28.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/jest": "^29",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"jest": "^29",
|
|
75
75
|
"nock": "^13.2.1",
|
|
76
76
|
"typescript": "^5",
|
|
77
|
-
"@
|
|
78
|
-
"@scripts/build": "2.
|
|
79
|
-
"@
|
|
77
|
+
"@scripts/jest-config": "2.28.0",
|
|
78
|
+
"@scripts/build": "2.28.0",
|
|
79
|
+
"@modern-js/types": "2.28.0"
|
|
80
80
|
},
|
|
81
81
|
"sideEffects": false,
|
|
82
82
|
"publishConfig": {
|