qmwts 1.1.48 → 1.1.50

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
@@ -4,11 +4,10 @@ export type { XIRREntity } from './utils/finance-utils';
4
4
  import Downloader from './utils/downloader';
5
5
  import NumberUtils from './utils/number-utils';
6
6
  import JsonUtils from './utils/json-utils';
7
- import UUIDUtils from './utils/uuid-utils';
8
7
  import PrototypeUtils from './utils/prototype-utils';
9
8
  import RequestDataGenerator from './utils/request-data-generator';
10
9
  import FileUtils from './utils/file-utils';
11
10
  import LocalDate from './class/local-date';
12
11
  import LocalDateTime from './class/local-date-time';
13
12
  import YearMonth from './class/year-month';
14
- export { Downloader, NumberUtils, JsonUtils, UUIDUtils, PrototypeUtils, RequestDataGenerator, FileUtils, LocalDate, LocalDateTime, YearMonth, };
13
+ export { Downloader, NumberUtils, JsonUtils, PrototypeUtils, RequestDataGenerator, FileUtils, LocalDate, LocalDateTime, YearMonth, };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.YearMonth = exports.LocalDateTime = exports.LocalDate = exports.FileUtils = exports.RequestDataGenerator = exports.PrototypeUtils = exports.UUIDUtils = exports.JsonUtils = exports.NumberUtils = exports.Downloader = exports.FinanceUtils = exports.ArrayUtils = void 0;
3
+ exports.YearMonth = exports.LocalDateTime = exports.LocalDate = exports.FileUtils = exports.RequestDataGenerator = exports.PrototypeUtils = exports.JsonUtils = exports.NumberUtils = exports.Downloader = exports.FinanceUtils = exports.ArrayUtils = void 0;
4
4
  // https://www.jianshu.com/p/8fa2c50720e4
5
5
  var array_utils_1 = require("./utils/array-utils");
6
6
  Object.defineProperty(exports, "ArrayUtils", { enumerable: true, get: function () { return array_utils_1.default; } });
@@ -12,8 +12,6 @@ var number_utils_1 = require("./utils/number-utils");
12
12
  exports.NumberUtils = number_utils_1.default;
13
13
  var json_utils_1 = require("./utils/json-utils");
14
14
  exports.JsonUtils = json_utils_1.default;
15
- var uuid_utils_1 = require("./utils/uuid-utils");
16
- exports.UUIDUtils = uuid_utils_1.default;
17
15
  var prototype_utils_1 = require("./utils/prototype-utils");
18
16
  exports.PrototypeUtils = prototype_utils_1.default;
19
17
  var request_data_generator_1 = require("./utils/request-data-generator");
@@ -6,6 +6,6 @@ declare const _default: {
6
6
  * @param parentKey 关联上级字段
7
7
  * @param childrenKey 下级字段
8
8
  */
9
- arrayToTree<T>(array?: any[], idKey?: string, parentKey?: string, childrenKey?: string): T[];
9
+ treeify<T>(array?: any[], idKey?: string, parentKey?: string, childrenKey?: string): T[];
10
10
  };
11
11
  export default _default;
@@ -19,7 +19,7 @@ exports.default = {
19
19
  * @param parentKey 关联上级字段
20
20
  * @param childrenKey 下级字段
21
21
  */
22
- arrayToTree: function (array, idKey, parentKey, childrenKey) {
22
+ treeify: function (array, idKey, parentKey, childrenKey) {
23
23
  if (array === void 0) { array = []; }
24
24
  if (idKey === void 0) { idKey = 'id'; }
25
25
  if (parentKey === void 0) { parentKey = 'parentId'; }
@@ -3,7 +3,7 @@ declare const _default: {
3
3
  isArray(o: any): boolean;
4
4
  parseObject<T>(o: any): T;
5
5
  parseArray<T>(o: any): T[];
6
- optionalChaining(o: any, chain: string, substitute?: any): any;
6
+ optionalChaining(o: any | undefined, chain: string, substitute?: any): any;
7
7
  setNull(o?: any, exclusions?: any): void;
8
8
  };
9
9
  export default _default;
@@ -10,10 +10,12 @@ exports.default = {
10
10
  for (var _i = 0; _i < arguments.length; _i++) {
11
11
  number[_i] = arguments[_i];
12
12
  }
13
- return number.every(function (e) {
14
- e = String(e).trim();
15
- return e !== '' && isFinite(e) && !isNaN(e);
16
- });
13
+ for (var i = number.length - 1; i >= 0; i--) {
14
+ var e = String(number[i]).trim();
15
+ if (e === '' || !isFinite(+e) || isNaN(+e))
16
+ return false;
17
+ }
18
+ return true;
17
19
  },
18
20
  // 增加千分位分隔符
19
21
  thousandths: function (number, fixed) {
@@ -29,8 +31,13 @@ exports.default = {
29
31
  return number;
30
32
  },
31
33
  summation: function (array) {
32
- var _this = this;
33
34
  if (array === void 0) { array = []; }
34
- return array.reduce(function (prev, curr) { return prev + _this.ifNaN(curr, 0); }, 0);
35
+ var sum = 0;
36
+ for (var i = array.length - 1; i >= 0; i--) {
37
+ var e = +array[i];
38
+ if (this.isNumber(e))
39
+ sum += e;
40
+ }
41
+ return sum;
35
42
  },
36
43
  };
@@ -1,4 +1,4 @@
1
1
  declare const _default: {
2
- generate(data: any, params: FormData | URLSearchParams): FormData | URLSearchParams;
2
+ generate(data: any | undefined, params: FormData | URLSearchParams): FormData | URLSearchParams;
3
3
  };
4
4
  export default _default;
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ trimAll(str: any): string;
3
+ uuid(withDash?: boolean): string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ trimAll: function (str) {
5
+ if ([void 0, null].includes(str))
6
+ return '';
7
+ return String(str).split('').map(function (e) { return e.trim(); }).join('');
8
+ },
9
+ uuid: function (withDash) {
10
+ if (withDash === void 0) { withDash = false; }
11
+ return ['xxxxxxxx', 'xxxx', '4xxx', 'yxxx', 'xxxxxxxxxxxx'].join(withDash ? '-' : '').replace(/[xy]/g, function (c) {
12
+ var r = (Math.random() * 16) | 0;
13
+ var v = c === 'x' ? r : (r & 0x3) | 0x8;
14
+ return v.toString(16);
15
+ });
16
+ }
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qmwts",
3
- "version": "1.1.48",
3
+ "version": "1.1.50",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "devDependencies": {
14
14
  "jest": "^29.7.0",
15
15
  "ts-jest": "^29.2.5",
16
- "typescript": "^5.6.3"
16
+ "typescript": "^5.8.2"
17
17
  },
18
18
  "files": [
19
19
  "dist"