keq 2.0.1 → 2.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/CHANGELOG.md +14 -0
- package/dist/umd/src/constant.d.ts +1 -0
- package/dist/umd/src/constant.js +14 -0
- package/dist/umd/src/core.d.ts +28 -0
- package/dist/umd/src/core.js +125 -0
- package/dist/umd/src/create-request.d.ts +8 -0
- package/dist/umd/src/create-request.js +126 -0
- package/dist/umd/src/exception/exception.d.ts +4 -0
- package/dist/umd/src/exception/exception.js +21 -0
- package/dist/umd/src/exception/file-expected.exception.d.ts +4 -0
- package/dist/umd/src/exception/file-expected.exception.js +20 -0
- package/dist/umd/src/exception/invalid-arguments.exception.d.ts +4 -0
- package/dist/umd/src/exception/invalid-arguments.exception.js +20 -0
- package/dist/umd/src/exception/overwrite-array-body.exception.d.ts +4 -0
- package/dist/umd/src/exception/overwrite-array-body.exception.js +20 -0
- package/dist/umd/src/index.d.ts +13 -0
- package/dist/umd/src/index.js +21 -0
- package/dist/umd/src/is/is-blob.d.ts +4 -0
- package/dist/umd/src/is/is-blob.js +32 -0
- package/dist/umd/src/is/is-browser.d.ts +1 -0
- package/dist/umd/src/is/is-browser.js +17 -0
- package/dist/umd/src/is/is-file.d.ts +1 -0
- package/dist/umd/src/is/is-file.js +21 -0
- package/dist/umd/src/is/is-form-data.d.ts +1 -0
- package/dist/umd/src/is/is-form-data.js +30 -0
- package/dist/umd/src/is/is-function.d.ts +1 -0
- package/dist/umd/src/is/is-function.js +17 -0
- package/dist/umd/src/is/is-headers.d.ts +1 -0
- package/dist/umd/src/is/is-headers.js +33 -0
- package/dist/umd/src/is/is-object.d.ts +1 -0
- package/dist/umd/src/is/is-object.js +17 -0
- package/dist/umd/src/is/is-string.d.ts +1 -0
- package/dist/umd/src/is/is-string.js +17 -0
- package/dist/umd/src/is/is-url-search-params.d.ts +1 -0
- package/dist/umd/src/is/is-url-search-params.js +36 -0
- package/dist/umd/src/keq.d.ts +70 -0
- package/dist/umd/src/keq.js +193 -0
- package/dist/umd/src/middleware.d.ts +2 -0
- package/dist/umd/src/middleware.js +27 -0
- package/dist/umd/src/middlewares/fetch-arguments-middleware.d.ts +2 -0
- package/dist/umd/src/middlewares/fetch-arguments-middleware.js +96 -0
- package/dist/umd/src/middlewares/fetch-middleware.d.ts +5 -0
- package/dist/umd/src/middlewares/fetch-middleware.js +29 -0
- package/dist/umd/src/middlewares/proxy-response-middleware.d.ts +2 -0
- package/dist/umd/src/middlewares/proxy-response-middleware.js +27 -0
- package/dist/umd/src/middlewares/retry-middleware.d.ts +2 -0
- package/dist/umd/src/middlewares/retry-middleware.js +51 -0
- package/dist/umd/src/request.d.ts +1 -0
- package/dist/umd/src/request.js +15 -0
- package/dist/umd/src/router/keq-host-router.d.ts +7 -0
- package/dist/umd/src/router/keq-host-router.js +33 -0
- package/dist/umd/src/router/keq-location-router.d.ts +6 -0
- package/dist/umd/src/router/keq-location-router.js +32 -0
- package/dist/umd/src/router/keq-method-router.d.ts +8 -0
- package/dist/umd/src/router/keq-method-router.js +33 -0
- package/dist/umd/src/router/keq-module-router.d.ts +7 -0
- package/dist/umd/src/router/keq-module-router.js +37 -0
- package/dist/umd/src/router/keq-pathname-router.d.ts +7 -0
- package/dist/umd/src/router/keq-pathname-router.js +34 -0
- package/dist/umd/src/router/keq-router.d.ts +7 -0
- package/dist/umd/src/router/keq-router.js +24 -0
- package/dist/umd/src/types/keq-context.d.ts +41 -0
- package/dist/umd/src/types/keq-context.js +13 -0
- package/dist/umd/src/types/keq-middleware.d.ts +3 -0
- package/dist/umd/src/types/keq-middleware.js +12 -0
- package/dist/umd/src/types/keq-next.d.ts +1 -0
- package/dist/umd/src/types/keq-next.js +12 -0
- package/dist/umd/src/types/keq-options.d.ts +38 -0
- package/dist/umd/src/types/keq-options.js +12 -0
- package/dist/umd/src/types/keq-request-body.d.ts +1 -0
- package/dist/umd/src/types/keq-request-body.js +12 -0
- package/dist/umd/src/types/keq-request-init.d.ts +2 -0
- package/dist/umd/src/types/keq-request-init.js +12 -0
- package/dist/umd/src/types/keq-request-method.d.ts +1 -0
- package/dist/umd/src/types/keq-request-method.js +12 -0
- package/dist/umd/src/types/keq-request.d.ts +21 -0
- package/dist/umd/src/types/keq-request.js +12 -0
- package/dist/umd/src/types/keq-retry-delay.d.ts +2 -0
- package/dist/umd/src/types/keq-retry-delay.js +12 -0
- package/dist/umd/src/types/keq-retry-on.d.ts +2 -0
- package/dist/umd/src/types/keq-retry-on.js +12 -0
- package/dist/umd/src/types/router-map.d.ts +9 -0
- package/dist/umd/src/types/router-map.js +12 -0
- package/dist/umd/src/types/shorthand-content-type.d.ts +1 -0
- package/dist/umd/src/types/shorthand-content-type.js +12 -0
- package/dist/umd/src/util/assign-keq-request-body.d.ts +2 -0
- package/dist/umd/src/util/assign-keq-request-body.js +70 -0
- package/dist/umd/src/util/base64.d.ts +2 -0
- package/dist/umd/src/util/base64.js +15 -0
- package/dist/umd/src/util/clone.d.ts +1 -0
- package/dist/umd/src/util/clone.js +38 -0
- package/dist/umd/src/util/fix-content-type.d.ts +2 -0
- package/dist/umd/src/util/fix-content-type.js +35 -0
- package/dist/umd/src/util/shadow-clone.d.ts +4 -0
- package/dist/umd/src/util/shadow-clone.js +27 -0
- package/package.json +6 -6
- package/tsconfig.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clone<T>(obj: T): T;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
|
+
};
|
|
4
|
+
(function (factory) {
|
|
5
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
6
|
+
var v = factory(require, exports);
|
|
7
|
+
if (v !== undefined) module.exports = v;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof define === "function" && define.amd) {
|
|
10
|
+
define(["require", "exports", "clone", "object.fromentries", "../is/is-blob"], factory);
|
|
11
|
+
}
|
|
12
|
+
})(function (require, exports) {
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.clone = void 0;
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
17
|
+
const clone_1 = __importDefault(require("clone"));
|
|
18
|
+
const object_fromentries_1 = __importDefault(require("object.fromentries"));
|
|
19
|
+
const is_blob_1 = require("../is/is-blob");
|
|
20
|
+
function clone(obj) {
|
|
21
|
+
if (Array.isArray(obj)) {
|
|
22
|
+
return obj.map((item) => ((0, is_blob_1.isBlob)(item) ? item : clone(item)));
|
|
23
|
+
}
|
|
24
|
+
else if (obj === null) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
else if (typeof obj === 'object') {
|
|
28
|
+
const entries = Object.entries(obj)
|
|
29
|
+
.map(([key, value]) => ([
|
|
30
|
+
key,
|
|
31
|
+
(0, is_blob_1.isBlob)(value) ? value : clone(value),
|
|
32
|
+
]));
|
|
33
|
+
return (0, object_fromentries_1.default)(entries);
|
|
34
|
+
}
|
|
35
|
+
return (0, clone_1.default)(obj);
|
|
36
|
+
}
|
|
37
|
+
exports.clone = clone;
|
|
38
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fixContentType = void 0;
|
|
13
|
+
function fixContentType(contentType) {
|
|
14
|
+
if (['json', 'xml'].includes(contentType)) {
|
|
15
|
+
return `application/${contentType}`;
|
|
16
|
+
}
|
|
17
|
+
else if (['html', 'css'].includes(contentType)) {
|
|
18
|
+
return `text/${contentType}`;
|
|
19
|
+
}
|
|
20
|
+
else if (['form-data'].includes(contentType)) {
|
|
21
|
+
return `multipart/${contentType}`;
|
|
22
|
+
}
|
|
23
|
+
else if (['jpeg', 'bmp', 'apng', 'gif', 'x-icon', 'png', 'webp', 'tiff'].includes(contentType)) {
|
|
24
|
+
return `image/${contentType}`;
|
|
25
|
+
}
|
|
26
|
+
else if (contentType === 'form') {
|
|
27
|
+
return 'application/x-www-form-urlencoded';
|
|
28
|
+
}
|
|
29
|
+
else if (contentType === 'svg') {
|
|
30
|
+
return 'image/svg+xml';
|
|
31
|
+
}
|
|
32
|
+
return contentType;
|
|
33
|
+
}
|
|
34
|
+
exports.fixContentType = fixContentType;
|
|
35
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "../is/is-object"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.shadowClone = void 0;
|
|
13
|
+
const is_object_1 = require("../is/is-object");
|
|
14
|
+
/**
|
|
15
|
+
* @description 浅拷贝
|
|
16
|
+
*/
|
|
17
|
+
function shadowClone(obj) {
|
|
18
|
+
if (Array.isArray(obj)) {
|
|
19
|
+
return [...obj];
|
|
20
|
+
}
|
|
21
|
+
else if ((0, is_object_1.isObject)(obj)) {
|
|
22
|
+
return { ...obj };
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
exports.shadowClone = shadowClone;
|
|
27
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keq",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"main": "dist/umd/src/index.js",
|
|
5
5
|
"types": "dist/esm/src/index.d.ts",
|
|
6
6
|
"module": "dist/esm/src/index.js",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"@commitlint/cli": "^17.7.1",
|
|
48
48
|
"@commitlint/config-conventional": "^17.7.0",
|
|
49
49
|
"@jest/globals": "^29.7.0",
|
|
50
|
-
"@rushstack/eslint-patch": "^1.
|
|
50
|
+
"@rushstack/eslint-patch": "^1.5.0",
|
|
51
51
|
"@types/clone": "^2.1.2",
|
|
52
52
|
"@types/minimatch": "^5.1.2",
|
|
53
|
-
"@types/node": "^20.
|
|
54
|
-
"@types/whatwg-url": "^11.0.
|
|
55
|
-
"@typescript-eslint/eslint-plugin": "^6.7.
|
|
56
|
-
"@typescript-eslint/parser": "^6.7.
|
|
53
|
+
"@types/node": "^20.7.0",
|
|
54
|
+
"@types/whatwg-url": "^11.0.1",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^6.7.3",
|
|
56
|
+
"@typescript-eslint/parser": "^6.7.3",
|
|
57
57
|
"eslint": "^8.50.0",
|
|
58
58
|
"husky": "^8.0.3",
|
|
59
59
|
"is-ci": "^3.0.1",
|
package/tsconfig.json
CHANGED