qmwts 1.1.43 → 1.1.45

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.
@@ -1,7 +1,8 @@
1
1
  export default class LocalDate {
2
- private date;
3
- constructor(...args: any[]);
4
- static now: () => LocalDate;
5
- static of: (year: any, month: any, date: any) => LocalDate;
6
- toString: () => string;
2
+ private readonly date;
3
+ constructor();
4
+ constructor(date: Date);
5
+ static now(): LocalDate;
6
+ static of(year: number, month: number, date: number): LocalDate;
7
+ toString(): string;
7
8
  }
@@ -1,37 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var number_utils_1 = require("../utils/number-utils");
4
- var prototype_utils_1 = require("../utils/prototype-utils");
5
3
  // https://juejin.cn/post/7098891689955164168
6
4
  var LocalDate = /** @class */ (function () {
7
- function LocalDate() {
8
- var args = [];
9
- for (var _i = 0; _i < arguments.length; _i++) {
10
- args[_i] = arguments[_i];
11
- }
12
- var _this = this;
13
- this.toString = function () {
14
- return [
15
- _this.date.getFullYear(),
16
- number_utils_1.default.leftPadZero(_this.date.getMonth() + 1, 2),
17
- number_utils_1.default.leftPadZero(_this.date.getDate(), 2)
18
- ].join('-');
19
- };
20
- this.date = new Date();
21
- if (number_utils_1.default.isNumber(args[0]))
22
- this.date.setFullYear(+args[0]);
23
- if (number_utils_1.default.isNumber(args[1]))
24
- this.date.setMonth(+args[1] - 1);
25
- if (number_utils_1.default.isNumber(args[2]))
26
- this.date.setDate(args[2]);
27
- if (prototype_utils_1.default.isDate(args[0]))
28
- this.date = args[0];
5
+ function LocalDate(date) {
6
+ if (date == void 0)
7
+ this.date = new Date();
8
+ else
9
+ this.date = date;
29
10
  }
30
11
  LocalDate.now = function () {
31
12
  return new LocalDate();
32
13
  };
33
14
  LocalDate.of = function (year, month, date) {
34
- return new LocalDate(year, month, date);
15
+ return new LocalDate(new Date(year, month - 1, date));
16
+ };
17
+ LocalDate.prototype.toString = function () {
18
+ return [
19
+ this.date.getFullYear().toString(),
20
+ (this.date.getMonth() + 1).toString().padStart(2, '0'),
21
+ this.date.getDate().toString().padStart(2, '0')
22
+ ].join('-');
35
23
  };
36
24
  return LocalDate;
37
25
  }());
@@ -1,7 +1,8 @@
1
1
  export default class YearMonth {
2
- private date;
3
- constructor(...args: any[]);
4
- static now: () => YearMonth;
5
- static of: (year: any, month: any) => YearMonth;
6
- toString: () => string;
2
+ private readonly date;
3
+ constructor();
4
+ constructor(date: Date);
5
+ static now(): YearMonth;
6
+ static of(year: number, month: number): YearMonth;
7
+ toString(): string;
7
8
  }
@@ -1,33 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var number_utils_1 = require("../utils/number-utils");
4
- var prototype_utils_1 = require("../utils/prototype-utils");
5
3
  var YearMonth = /** @class */ (function () {
6
- function YearMonth() {
7
- var args = [];
8
- for (var _i = 0; _i < arguments.length; _i++) {
9
- args[_i] = arguments[_i];
10
- }
11
- var _this = this;
12
- this.toString = function () {
13
- return [
14
- _this.date.getFullYear(),
15
- number_utils_1.default.leftPadZero(_this.date.getMonth() + 1, 2)
16
- ].join('-');
17
- };
18
- this.date = new Date();
19
- if (number_utils_1.default.isNumber(args[0]))
20
- this.date.setFullYear(+args[0]);
21
- if (number_utils_1.default.isNumber(args[1]))
22
- this.date.setMonth(+args[1] - 1);
23
- if (prototype_utils_1.default.isDate(args[0]))
24
- this.date = args[0];
4
+ function YearMonth(date) {
5
+ if (date == void 0)
6
+ this.date = new Date();
7
+ else
8
+ this.date = date;
25
9
  }
26
10
  YearMonth.now = function () {
27
11
  return new YearMonth();
28
12
  };
29
13
  YearMonth.of = function (year, month) {
30
- return new YearMonth(year, month);
14
+ return new YearMonth(new Date(year, month - 1));
15
+ };
16
+ YearMonth.prototype.toString = function () {
17
+ return [
18
+ this.date.getFullYear().toString(),
19
+ (this.date.getMonth() + 1).toString().padStart(2, '0')
20
+ ].join('-');
31
21
  };
32
22
  return YearMonth;
33
23
  }());
package/dist/index.d.ts CHANGED
@@ -6,8 +6,7 @@ import UUIDUtils from './utils/uuid-utils';
6
6
  import PrototypeUtils from './utils/prototype-utils';
7
7
  import RequestDataGenerator from './utils/request-data-generator';
8
8
  import FileUtils from './utils/file-utils';
9
- import DateUtils from './utils/date-utils';
10
9
  import LocalDate from './class/local-date';
11
10
  import LocalDateTime from './class/local-date-time';
12
11
  import YearMonth from './class/year-month';
13
- export { ArrayUtils, Downloader, NumberUtils, JsonUtils, UUIDUtils, PrototypeUtils, RequestDataGenerator, FileUtils, DateUtils, LocalDate, LocalDateTime, YearMonth, };
12
+ export { ArrayUtils, Downloader, NumberUtils, JsonUtils, UUIDUtils, 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.DateUtils = exports.FileUtils = exports.RequestDataGenerator = exports.PrototypeUtils = exports.UUIDUtils = exports.JsonUtils = exports.NumberUtils = exports.Downloader = exports.ArrayUtils = void 0;
3
+ exports.YearMonth = exports.LocalDateTime = exports.LocalDate = exports.FileUtils = exports.RequestDataGenerator = exports.PrototypeUtils = exports.UUIDUtils = exports.JsonUtils = exports.NumberUtils = exports.Downloader = exports.ArrayUtils = void 0;
4
4
  // https://www.jianshu.com/p/8fa2c50720e4
5
5
  var array_utils_1 = require("./utils/array-utils");
6
6
  exports.ArrayUtils = array_utils_1.default;
@@ -18,8 +18,6 @@ var request_data_generator_1 = require("./utils/request-data-generator");
18
18
  exports.RequestDataGenerator = request_data_generator_1.default;
19
19
  var file_utils_1 = require("./utils/file-utils");
20
20
  exports.FileUtils = file_utils_1.default;
21
- var date_utils_1 = require("./utils/date-utils");
22
- exports.DateUtils = date_utils_1.default;
23
21
  var local_date_1 = require("./class/local-date");
24
22
  exports.LocalDate = local_date_1.default;
25
23
  var local_date_time_1 = require("./class/local-date-time");
@@ -6,6 +6,6 @@ declare const _default: {
6
6
  * @param parentKey 关联上级字段
7
7
  * @param childrenKey 下级字段
8
8
  */
9
- listToTree<T>(array?: any[], idKey?: string, parentKey?: string, childrenKey?: string): T[];
9
+ arrayToTree<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
- listToTree: function (array, idKey, parentKey, childrenKey) {
22
+ arrayToTree: 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,6 +3,5 @@ declare const _default: {
3
3
  isNumber(...number: any[]): boolean;
4
4
  thousandths(number: any, fixed?: number): string;
5
5
  summation(array?: any[]): number;
6
- leftPadZero(num: number, pad: number): string;
7
6
  };
8
7
  export default _default;
@@ -33,7 +33,4 @@ exports.default = {
33
33
  if (array === void 0) { array = []; }
34
34
  return array.reduce(function (prev, curr) { return prev + _this.ifNaN(curr, 0); }, 0);
35
35
  },
36
- leftPadZero: function (num, pad) {
37
- return ('0' + num).slice(-pad);
38
- }
39
36
  };
@@ -1,4 +1,5 @@
1
1
  declare const _default: {
2
+ is(o: any, type: string): boolean;
2
3
  isObject(o: any): boolean;
3
4
  isArray(o: any): boolean;
4
5
  isFile(o: any): boolean;
@@ -1,28 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
+ is: function (o, type) {
5
+ return Object.prototype.toString.call(o) === "[object ".concat(type, "]");
6
+ },
4
7
  isObject: function (o) {
5
- return Object.prototype.toString.call(o) === '[object Object]';
8
+ return this.is(o, 'Object');
6
9
  },
7
10
  isArray: function (o) {
8
- return Object.prototype.toString.call(o) === '[object Array]';
11
+ return this.is(o, 'Array');
9
12
  },
10
13
  isFile: function (o) {
11
- return Object.prototype.toString.call(o) === '[object File]';
14
+ return this.is(o, 'File');
12
15
  },
13
16
  isNumber: function (o) {
14
- return Object.prototype.toString.call(o) === '[object Number]';
17
+ return this.is(o, 'Number');
15
18
  },
16
19
  isDate: function (o) {
17
- return Object.prototype.toString.call(o) === '[object Date]';
20
+ return this.is(o, 'Date');
18
21
  },
19
22
  isFunction: function (o) {
20
- return Object.prototype.toString.call(o) === '[object Function]';
23
+ return this.is(o, 'Function');
21
24
  },
22
25
  isBoolean: function (o) {
23
- return Object.prototype.toString.call(o) === '[object Boolean]';
26
+ return this.is(o, 'Boolean');
24
27
  },
25
28
  isString: function (o) {
26
- return Object.prototype.toString.call(o) === '[object String]';
29
+ return this.is(o, 'String');
27
30
  },
28
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qmwts",
3
- "version": "1.1.43",
3
+ "version": "1.1.45",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,7 +11,6 @@
11
11
  "author": "qmw",
12
12
  "license": "ISC",
13
13
  "devDependencies": {
14
- "@types/node": "^22.7.5",
15
14
  "jest": "^29.7.0",
16
15
  "ts-jest": "^29.2.5",
17
16
  "typescript": "^5.6.3"