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.
Files changed (97) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/umd/src/constant.d.ts +1 -0
  3. package/dist/umd/src/constant.js +14 -0
  4. package/dist/umd/src/core.d.ts +28 -0
  5. package/dist/umd/src/core.js +125 -0
  6. package/dist/umd/src/create-request.d.ts +8 -0
  7. package/dist/umd/src/create-request.js +126 -0
  8. package/dist/umd/src/exception/exception.d.ts +4 -0
  9. package/dist/umd/src/exception/exception.js +21 -0
  10. package/dist/umd/src/exception/file-expected.exception.d.ts +4 -0
  11. package/dist/umd/src/exception/file-expected.exception.js +20 -0
  12. package/dist/umd/src/exception/invalid-arguments.exception.d.ts +4 -0
  13. package/dist/umd/src/exception/invalid-arguments.exception.js +20 -0
  14. package/dist/umd/src/exception/overwrite-array-body.exception.d.ts +4 -0
  15. package/dist/umd/src/exception/overwrite-array-body.exception.js +20 -0
  16. package/dist/umd/src/index.d.ts +13 -0
  17. package/dist/umd/src/index.js +21 -0
  18. package/dist/umd/src/is/is-blob.d.ts +4 -0
  19. package/dist/umd/src/is/is-blob.js +32 -0
  20. package/dist/umd/src/is/is-browser.d.ts +1 -0
  21. package/dist/umd/src/is/is-browser.js +17 -0
  22. package/dist/umd/src/is/is-file.d.ts +1 -0
  23. package/dist/umd/src/is/is-file.js +21 -0
  24. package/dist/umd/src/is/is-form-data.d.ts +1 -0
  25. package/dist/umd/src/is/is-form-data.js +30 -0
  26. package/dist/umd/src/is/is-function.d.ts +1 -0
  27. package/dist/umd/src/is/is-function.js +17 -0
  28. package/dist/umd/src/is/is-headers.d.ts +1 -0
  29. package/dist/umd/src/is/is-headers.js +33 -0
  30. package/dist/umd/src/is/is-object.d.ts +1 -0
  31. package/dist/umd/src/is/is-object.js +17 -0
  32. package/dist/umd/src/is/is-string.d.ts +1 -0
  33. package/dist/umd/src/is/is-string.js +17 -0
  34. package/dist/umd/src/is/is-url-search-params.d.ts +1 -0
  35. package/dist/umd/src/is/is-url-search-params.js +36 -0
  36. package/dist/umd/src/keq.d.ts +70 -0
  37. package/dist/umd/src/keq.js +193 -0
  38. package/dist/umd/src/middleware.d.ts +2 -0
  39. package/dist/umd/src/middleware.js +27 -0
  40. package/dist/umd/src/middlewares/fetch-arguments-middleware.d.ts +2 -0
  41. package/dist/umd/src/middlewares/fetch-arguments-middleware.js +96 -0
  42. package/dist/umd/src/middlewares/fetch-middleware.d.ts +5 -0
  43. package/dist/umd/src/middlewares/fetch-middleware.js +29 -0
  44. package/dist/umd/src/middlewares/proxy-response-middleware.d.ts +2 -0
  45. package/dist/umd/src/middlewares/proxy-response-middleware.js +27 -0
  46. package/dist/umd/src/middlewares/retry-middleware.d.ts +2 -0
  47. package/dist/umd/src/middlewares/retry-middleware.js +51 -0
  48. package/dist/umd/src/request.d.ts +1 -0
  49. package/dist/umd/src/request.js +15 -0
  50. package/dist/umd/src/router/keq-host-router.d.ts +7 -0
  51. package/dist/umd/src/router/keq-host-router.js +33 -0
  52. package/dist/umd/src/router/keq-location-router.d.ts +6 -0
  53. package/dist/umd/src/router/keq-location-router.js +32 -0
  54. package/dist/umd/src/router/keq-method-router.d.ts +8 -0
  55. package/dist/umd/src/router/keq-method-router.js +33 -0
  56. package/dist/umd/src/router/keq-module-router.d.ts +7 -0
  57. package/dist/umd/src/router/keq-module-router.js +37 -0
  58. package/dist/umd/src/router/keq-pathname-router.d.ts +7 -0
  59. package/dist/umd/src/router/keq-pathname-router.js +34 -0
  60. package/dist/umd/src/router/keq-router.d.ts +7 -0
  61. package/dist/umd/src/router/keq-router.js +24 -0
  62. package/dist/umd/src/types/keq-context.d.ts +41 -0
  63. package/dist/umd/src/types/keq-context.js +13 -0
  64. package/dist/umd/src/types/keq-middleware.d.ts +3 -0
  65. package/dist/umd/src/types/keq-middleware.js +12 -0
  66. package/dist/umd/src/types/keq-next.d.ts +1 -0
  67. package/dist/umd/src/types/keq-next.js +12 -0
  68. package/dist/umd/src/types/keq-options.d.ts +38 -0
  69. package/dist/umd/src/types/keq-options.js +12 -0
  70. package/dist/umd/src/types/keq-request-body.d.ts +1 -0
  71. package/dist/umd/src/types/keq-request-body.js +12 -0
  72. package/dist/umd/src/types/keq-request-init.d.ts +2 -0
  73. package/dist/umd/src/types/keq-request-init.js +12 -0
  74. package/dist/umd/src/types/keq-request-method.d.ts +1 -0
  75. package/dist/umd/src/types/keq-request-method.js +12 -0
  76. package/dist/umd/src/types/keq-request.d.ts +21 -0
  77. package/dist/umd/src/types/keq-request.js +12 -0
  78. package/dist/umd/src/types/keq-retry-delay.d.ts +2 -0
  79. package/dist/umd/src/types/keq-retry-delay.js +12 -0
  80. package/dist/umd/src/types/keq-retry-on.d.ts +2 -0
  81. package/dist/umd/src/types/keq-retry-on.js +12 -0
  82. package/dist/umd/src/types/router-map.d.ts +9 -0
  83. package/dist/umd/src/types/router-map.js +12 -0
  84. package/dist/umd/src/types/shorthand-content-type.d.ts +1 -0
  85. package/dist/umd/src/types/shorthand-content-type.js +12 -0
  86. package/dist/umd/src/util/assign-keq-request-body.d.ts +2 -0
  87. package/dist/umd/src/util/assign-keq-request-body.js +70 -0
  88. package/dist/umd/src/util/base64.d.ts +2 -0
  89. package/dist/umd/src/util/base64.js +15 -0
  90. package/dist/umd/src/util/clone.d.ts +1 -0
  91. package/dist/umd/src/util/clone.js +38 -0
  92. package/dist/umd/src/util/fix-content-type.d.ts +2 -0
  93. package/dist/umd/src/util/fix-content-type.js +35 -0
  94. package/dist/umd/src/util/shadow-clone.d.ts +4 -0
  95. package/dist/umd/src/util/shadow-clone.js +27 -0
  96. package/package.json +6 -6
  97. 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,2 @@
1
+ import { ShorthandContentType } from "../types/shorthand-content-type";
2
+ export declare function fixContentType(contentType: ShorthandContentType | string): string;
@@ -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,4 @@
1
+ /**
2
+ * @description 浅拷贝
3
+ */
4
+ export declare function shadowClone<T = any>(obj: T): T;
@@ -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.1",
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.4.0",
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.6.5",
54
- "@types/whatwg-url": "^11.0.0",
55
- "@typescript-eslint/eslint-plugin": "^6.7.2",
56
- "@typescript-eslint/parser": "^6.7.2",
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
@@ -5,8 +5,8 @@
5
5
  "esModuleInterop": true,
6
6
  "noImplicitAny": false,
7
7
  "declaration": true,
8
- "resolveJsonModule": true,
9
8
  "noEmitOnError": true,
9
+ "resolveJsonModule": true,
10
10
  "skipLibCheck": true,
11
11
  "moduleResolution": "node",
12
12
  "module": "ESNext",