qmwts 1.1.65 → 1.1.67
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 +1 -0
- package/dist/class/local-date.js +6 -3
- package/dist/utils/number-utils.d.ts +7 -6
- package/dist/utils/number-utils.js +39 -19
- package/dist/utils/object-utils.js +1 -1
- package/dist/utils/request-data-generator.js +1 -4
- package/dist/utils/string-utils.js +1 -1
- package/package.json +1 -1
package/dist/class/local-date.js
CHANGED
|
@@ -3,14 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// https://juejin.cn/post/7098891689955164168
|
|
4
4
|
class LocalDate {
|
|
5
5
|
constructor(date) {
|
|
6
|
-
if (date
|
|
7
|
-
this.date = new Date();
|
|
8
|
-
else
|
|
6
|
+
if (date instanceof Date)
|
|
9
7
|
this.date = date;
|
|
8
|
+
else
|
|
9
|
+
this.date = new Date();
|
|
10
10
|
}
|
|
11
11
|
static now() {
|
|
12
12
|
return new LocalDate();
|
|
13
13
|
}
|
|
14
|
+
static parse(date) {
|
|
15
|
+
return new LocalDate(new Date(date));
|
|
16
|
+
}
|
|
14
17
|
static of(year, month, date) {
|
|
15
18
|
return new LocalDate(new Date(year, month - 1, date));
|
|
16
19
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
ifNaN(
|
|
3
|
-
isNumber(...
|
|
4
|
-
thousandths(
|
|
5
|
-
summation(
|
|
6
|
-
isBetween(
|
|
7
|
-
isInside(
|
|
2
|
+
ifNaN(value: any, substitute: any): any;
|
|
3
|
+
isNumber(...values: any[]): boolean;
|
|
4
|
+
thousandths(value: any, fixed?: number): string;
|
|
5
|
+
summation(...values: any[]): number;
|
|
6
|
+
isBetween(value: number, min: number, max: number): boolean;
|
|
7
|
+
isInside(value: number, min: number, max: number): boolean;
|
|
8
|
+
extractNumbers(value: any): string;
|
|
8
9
|
};
|
|
9
10
|
export default _default;
|
|
@@ -2,42 +2,62 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = {
|
|
4
4
|
// 判断是否数字
|
|
5
|
-
ifNaN(
|
|
6
|
-
return this.isNumber(
|
|
5
|
+
ifNaN(value, substitute) {
|
|
6
|
+
return this.isNumber(value) ? +value : substitute;
|
|
7
7
|
},
|
|
8
|
-
isNumber(...
|
|
9
|
-
for (let i =
|
|
10
|
-
const e = String(
|
|
11
|
-
if (e === '' || !isFinite(+e) || isNaN(+e))
|
|
8
|
+
isNumber(...values) {
|
|
9
|
+
for (let i = values.length - 1; i >= 0; i--) {
|
|
10
|
+
const e = String(values[i]).trim();
|
|
11
|
+
if (e === '' || !Number.isFinite(+e) || Number.isNaN(+e))
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
return true;
|
|
15
15
|
},
|
|
16
16
|
// 增加千分位分隔符
|
|
17
|
-
thousandths(
|
|
18
|
-
if (!this.isNumber(
|
|
17
|
+
thousandths(value, fixed = 2) {
|
|
18
|
+
if (!this.isNumber(value))
|
|
19
19
|
return '';
|
|
20
|
-
|
|
20
|
+
value = new Intl.NumberFormat('en-US', {
|
|
21
21
|
minimumFractionDigits: fixed,
|
|
22
22
|
maximumFractionDigits: fixed,
|
|
23
|
-
}).format(
|
|
24
|
-
if (+
|
|
23
|
+
}).format(value);
|
|
24
|
+
if (+value === 0) // -0转为0
|
|
25
25
|
return (0).toFixed(fixed);
|
|
26
|
-
return
|
|
26
|
+
return value;
|
|
27
27
|
},
|
|
28
|
-
summation(
|
|
28
|
+
summation(...values) {
|
|
29
29
|
let sum = 0;
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const values0 = values.flat(Infinity);
|
|
31
|
+
for (let i = values0.length - 1; i >= 0; i--) {
|
|
32
|
+
const e = +values0[i];
|
|
32
33
|
if (this.isNumber(e))
|
|
33
34
|
sum += e;
|
|
34
35
|
}
|
|
35
36
|
return sum;
|
|
36
37
|
},
|
|
37
|
-
isBetween(
|
|
38
|
-
return
|
|
38
|
+
isBetween(value, min, max) {
|
|
39
|
+
return value >= Math.min(min, max) && value <= Math.max(max, min);
|
|
39
40
|
},
|
|
40
|
-
isInside(
|
|
41
|
-
return
|
|
41
|
+
isInside(value, min, max) {
|
|
42
|
+
return value > Math.min(min, max) && value < Math.max(max, min);
|
|
43
|
+
},
|
|
44
|
+
extractNumbers(value) {
|
|
45
|
+
const v = String(value);
|
|
46
|
+
let result = '';
|
|
47
|
+
let hasDot = false;
|
|
48
|
+
for (let i = 0; i < v.length; i++) {
|
|
49
|
+
const ch = v[i];
|
|
50
|
+
if (/[0-9]/.test(ch)) {
|
|
51
|
+
result += ch;
|
|
52
|
+
}
|
|
53
|
+
else if (ch === '-' && result === '') { // 负号只能在最前
|
|
54
|
+
result += ch;
|
|
55
|
+
}
|
|
56
|
+
else if (ch === '.' && !hasDot) { // 只能有一个小数点
|
|
57
|
+
result += ch;
|
|
58
|
+
hasDot = true;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
42
62
|
}
|
|
43
63
|
};
|
|
@@ -6,12 +6,9 @@ exports.default = {
|
|
|
6
6
|
if (Array.isArray(value))
|
|
7
7
|
for (const i of value)
|
|
8
8
|
params.append(key, i);
|
|
9
|
-
else if (
|
|
9
|
+
else if (value != null)
|
|
10
10
|
params.append(key, value);
|
|
11
11
|
}
|
|
12
12
|
return params;
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
function isValidValue(value) {
|
|
16
|
-
return value !== null && value !== void 0;
|
|
17
|
-
}
|