qmwts 1.1.13 → 1.1.14

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/index.d.ts CHANGED
@@ -2,4 +2,5 @@ import NumberUtils from './utils/number-utils';
2
2
  import JsonUtils from './utils/json-utils';
3
3
  import UUIDUtils from './utils/uuid-utils';
4
4
  import PrototypeUtils from './utils/prototype-utils';
5
- export { NumberUtils, JsonUtils, UUIDUtils, PrototypeUtils };
5
+ import RequestDataGenerator from './utils/request-data-generator';
6
+ export { NumberUtils, JsonUtils, UUIDUtils, PrototypeUtils, RequestDataGenerator, };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrototypeUtils = exports.UUIDUtils = exports.JsonUtils = exports.NumberUtils = void 0;
3
+ exports.RequestDataGenerator = exports.PrototypeUtils = exports.UUIDUtils = exports.JsonUtils = exports.NumberUtils = void 0;
4
4
  // https://www.jianshu.com/p/8fa2c50720e4
5
5
  var number_utils_1 = require("./utils/number-utils");
6
6
  exports.NumberUtils = number_utils_1.default;
@@ -10,3 +10,5 @@ var uuid_utils_1 = require("./utils/uuid-utils");
10
10
  exports.UUIDUtils = uuid_utils_1.default;
11
11
  var prototype_utils_1 = require("./utils/prototype-utils");
12
12
  exports.PrototypeUtils = prototype_utils_1.default;
13
+ var request_data_generator_1 = require("./utils/request-data-generator");
14
+ exports.RequestDataGenerator = request_data_generator_1.default;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ generateFormData(params?: any): FormData;
3
+ generateURLSearchParams(params?: any): URLSearchParams;
4
+ };
5
+ export default _default;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var prototype_utils_1 = require("./prototype-utils");
4
+ exports.default = {
5
+ generateFormData: function (params) {
6
+ if (params === void 0) { params = {}; }
7
+ var data = new FormData();
8
+ for (var _i = 0, _a = Object.entries(params); _i < _a.length; _i++) {
9
+ var _b = _a[_i], key = _b[0], value = _b[1];
10
+ if (prototype_utils_1.default.isArray(value)) // 数组循环append
11
+ for (var _c = 0, _d = value; _c < _d.length; _c++) {
12
+ var i = _d[_c];
13
+ data.append(key, i);
14
+ }
15
+ else if (isValidValue(value))
16
+ data.append(key, value);
17
+ }
18
+ return data;
19
+ },
20
+ generateURLSearchParams: function (params) {
21
+ if (params === void 0) { params = {}; }
22
+ return new URLSearchParams();
23
+ },
24
+ };
25
+ function isValidValue(value) {
26
+ return value !== null && value !== void 0;
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qmwts",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",