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.
- package/dist/class/local-date.d.ts +6 -5
- package/dist/class/local-date.js +13 -25
- package/dist/class/year-month.d.ts +6 -5
- package/dist/class/year-month.js +12 -22
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -3
- package/dist/utils/array-utils.d.ts +1 -1
- package/dist/utils/array-utils.js +1 -1
- package/dist/utils/number-utils.d.ts +0 -1
- package/dist/utils/number-utils.js +0 -3
- package/dist/utils/prototype-utils.d.ts +1 -0
- package/dist/utils/prototype-utils.js +11 -8
- package/package.json +1 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default class LocalDate {
|
|
2
|
-
private date;
|
|
3
|
-
constructor(
|
|
4
|
-
|
|
5
|
-
static
|
|
6
|
-
|
|
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
|
}
|
package/dist/class/local-date.js
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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(
|
|
4
|
-
|
|
5
|
-
static
|
|
6
|
-
|
|
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
|
}
|
package/dist/class/year-month.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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,
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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'; }
|
|
@@ -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
|
|
8
|
+
return this.is(o, 'Object');
|
|
6
9
|
},
|
|
7
10
|
isArray: function (o) {
|
|
8
|
-
return
|
|
11
|
+
return this.is(o, 'Array');
|
|
9
12
|
},
|
|
10
13
|
isFile: function (o) {
|
|
11
|
-
return
|
|
14
|
+
return this.is(o, 'File');
|
|
12
15
|
},
|
|
13
16
|
isNumber: function (o) {
|
|
14
|
-
return
|
|
17
|
+
return this.is(o, 'Number');
|
|
15
18
|
},
|
|
16
19
|
isDate: function (o) {
|
|
17
|
-
return
|
|
20
|
+
return this.is(o, 'Date');
|
|
18
21
|
},
|
|
19
22
|
isFunction: function (o) {
|
|
20
|
-
return
|
|
23
|
+
return this.is(o, 'Function');
|
|
21
24
|
},
|
|
22
25
|
isBoolean: function (o) {
|
|
23
|
-
return
|
|
26
|
+
return this.is(o, 'Boolean');
|
|
24
27
|
},
|
|
25
28
|
isString: function (o) {
|
|
26
|
-
return
|
|
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.
|
|
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"
|