@base-web-kits/base-tools-ts 0.9.9 → 0.9.12
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/base-tools-ts.umd.global.js +45 -40
- package/dist/base-tools-ts.umd.global.js.map +1 -1
- package/dist/day/index.d.ts +3 -3
- package/dist/day/index.d.ts.map +1 -1
- package/dist/index.cjs +54 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -40
- package/dist/index.js.map +1 -1
- package/dist/number/big.d.ts +33 -33
- package/dist/number/big.d.ts.map +1 -1
- package/dist/string/other.d.ts +13 -11
- package/dist/string/other.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ts/day/index.ts +3 -3
- package/src/ts/number/big.ts +41 -41
- package/src/ts/string/other.ts +36 -24
package/dist/day/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ type BaseTime = number | string | Date | dayjs.Dayjs | null | undefined;
|
|
|
7
7
|
* @param t 各种规范或不规范的时间
|
|
8
8
|
* @returns dayjs 实例
|
|
9
9
|
* @example
|
|
10
|
-
* const d = toDayjs('2021-01-01'); // dayjs 实例
|
|
10
|
+
* const d = toDayjs('2021-01-01'); // dayjs 实例 (无参,则默认当前时间)
|
|
11
11
|
* d.format('YYYY-MM-DD HH:mm:ss'); // "2025-12-10 11:33:16"
|
|
12
12
|
* d.valueOf(); // 毫秒时间戳,如 1765337596913
|
|
13
13
|
* d.unix(); // 秒时间戳,如 1765337596
|
|
@@ -35,7 +35,7 @@ type BaseTime = number | string | Date | dayjs.Dayjs | null | undefined;
|
|
|
35
35
|
* d.diff(t, 'quarter'); // 与t相差的季度数
|
|
36
36
|
* d.diff(t, 'year'); // 与t相差的年数
|
|
37
37
|
*/
|
|
38
|
-
export declare function toDayjs(t
|
|
38
|
+
export declare function toDayjs(t?: BaseTime, fmt?: dayjs.OptionType): dayjs.Dayjs;
|
|
39
39
|
/**
|
|
40
40
|
* 获取“前几天”的日期范围
|
|
41
41
|
* @param offset 正整数天数
|
|
@@ -66,7 +66,7 @@ export declare function getDateRangeAfter(offset: number, fmt?: string): string[
|
|
|
66
66
|
* @returns 包含天、时、分、秒、毫秒的零填充对象
|
|
67
67
|
* @example
|
|
68
68
|
* const diff = toDayjs(t).diff(); // 毫秒差值
|
|
69
|
-
* const parts = getCountdownParts(diff); // { d: '
|
|
69
|
+
* const parts = getCountdownParts(diff); // { d: '00', h: '00', m: '00', s: '00', ms: '000' }
|
|
70
70
|
*/
|
|
71
71
|
export declare function getCountdownParts(diff: number): {
|
|
72
72
|
d: string;
|
package/dist/day/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ts/day/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAU5B,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ts/day/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,oBAAoB,CAAC;AAU5B,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,UAAU,eAmB3D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAe,YASpE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,SAAe,YASnE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM;;;;;;EAgB7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM;;;EAqBlD;AAED;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -45,18 +45,19 @@ __export(index_exports, {
|
|
|
45
45
|
attempt: () => attempt_default,
|
|
46
46
|
before: () => before_default,
|
|
47
47
|
big: () => big,
|
|
48
|
-
bigAdd: () => bigAdd,
|
|
49
48
|
bigCompare: () => bigCompare,
|
|
50
49
|
bigDiv: () => bigDiv,
|
|
51
50
|
bigEqual: () => bigEqual,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
bigFixed: () => bigFixed,
|
|
52
|
+
bigGreaterThan: () => bigGreaterThan,
|
|
53
|
+
bigGreaterThanOrEqualTo: () => bigGreaterThanOrEqualTo,
|
|
54
|
+
bigLessThan: () => bigLessThan,
|
|
55
|
+
bigLessThanOrEqual: () => bigLessThanOrEqual,
|
|
56
|
+
bigMinus: () => bigMinus,
|
|
57
|
+
bigPlus: () => bigPlus,
|
|
57
58
|
bigPow: () => bigPow,
|
|
58
59
|
bigRound: () => bigRound,
|
|
59
|
-
|
|
60
|
+
bigTimes: () => bigTimes,
|
|
60
61
|
bind: () => bind_default,
|
|
61
62
|
bindAll: () => bindAll_default,
|
|
62
63
|
bindKey: () => bindKey_default,
|
|
@@ -143,6 +144,7 @@ __export(index_exports, {
|
|
|
143
144
|
functionsIn: () => functionsIn_default,
|
|
144
145
|
get: () => get_default,
|
|
145
146
|
getAgeByBirthdate: () => getAgeByBirthdate,
|
|
147
|
+
getByteLength: () => getByteLength,
|
|
146
148
|
getCountdownParts: () => getCountdownParts,
|
|
147
149
|
getDateRangeAfter: () => getDateRangeAfter,
|
|
148
150
|
getDateRangeBefore: () => getDateRangeBefore,
|
|
@@ -157,7 +159,6 @@ __export(index_exports, {
|
|
|
157
159
|
getQnHls: () => getQnHls,
|
|
158
160
|
getQnImg: () => getQnImg,
|
|
159
161
|
getQnVideo: () => getQnVideo,
|
|
160
|
-
getStringByteLength: () => getStringByteLength,
|
|
161
162
|
getUrlNumber: () => getUrlNumber,
|
|
162
163
|
getUrlParam: () => getUrlParam,
|
|
163
164
|
getUrlParamAll: () => getUrlParamAll,
|
|
@@ -370,7 +371,6 @@ __export(index_exports, {
|
|
|
370
371
|
toChineseNum: () => toChineseNum,
|
|
371
372
|
toDayjs: () => toDayjs,
|
|
372
373
|
toFinite: () => toFinite_default,
|
|
373
|
-
toFixed: () => toFixed,
|
|
374
374
|
toInteger: () => toInteger_default,
|
|
375
375
|
toIterator: () => toIterator_default,
|
|
376
376
|
toJSON: () => wrapperValue_default,
|
|
@@ -506,24 +506,24 @@ var import_bignumber = __toESM(require("bignumber.js"), 1);
|
|
|
506
506
|
function big(x) {
|
|
507
507
|
return x instanceof import_bignumber.default ? x : new import_bignumber.default(x);
|
|
508
508
|
}
|
|
509
|
-
function
|
|
510
|
-
let acc = big(
|
|
511
|
-
for (const x of rest2) acc = acc.plus(big(x));
|
|
509
|
+
function bigPlus(...rest2) {
|
|
510
|
+
let acc = big(rest2[0]);
|
|
511
|
+
for (const x of rest2.slice(1)) acc = acc.plus(big(x));
|
|
512
512
|
return acc.toNumber();
|
|
513
513
|
}
|
|
514
|
-
function
|
|
515
|
-
let acc = big(
|
|
516
|
-
for (const x of rest2) acc = acc.minus(big(x));
|
|
514
|
+
function bigMinus(...rest2) {
|
|
515
|
+
let acc = big(rest2[0]);
|
|
516
|
+
for (const x of rest2.slice(1)) acc = acc.minus(big(x));
|
|
517
517
|
return acc.toNumber();
|
|
518
518
|
}
|
|
519
|
-
function
|
|
520
|
-
let acc = big(
|
|
521
|
-
for (const x of rest2) acc = acc.times(big(x));
|
|
519
|
+
function bigTimes(...rest2) {
|
|
520
|
+
let acc = big(rest2[0]);
|
|
521
|
+
for (const x of rest2.slice(1)) acc = acc.times(big(x));
|
|
522
522
|
return acc.toNumber();
|
|
523
523
|
}
|
|
524
|
-
function bigDiv(
|
|
525
|
-
let acc = big(
|
|
526
|
-
for (const x of rest2) acc = acc.div(big(x));
|
|
524
|
+
function bigDiv(...rest2) {
|
|
525
|
+
let acc = big(rest2[0]);
|
|
526
|
+
for (const x of rest2.slice(1)) acc = acc.div(big(x));
|
|
527
527
|
return acc.toNumber();
|
|
528
528
|
}
|
|
529
529
|
function bigPow(x, y) {
|
|
@@ -532,7 +532,7 @@ function bigPow(x, y) {
|
|
|
532
532
|
function bigRound(x, dp = 0, rm = import_bignumber.default.ROUND_HALF_UP) {
|
|
533
533
|
return big(x).decimalPlaces(dp, rm).toNumber();
|
|
534
534
|
}
|
|
535
|
-
function
|
|
535
|
+
function bigFixed(x, dp = 2, rm = import_bignumber.default.ROUND_HALF_UP) {
|
|
536
536
|
return big(x).toFixed(dp, rm);
|
|
537
537
|
}
|
|
538
538
|
function bigCompare(a, b) {
|
|
@@ -541,16 +541,16 @@ function bigCompare(a, b) {
|
|
|
541
541
|
function bigEqual(a, b) {
|
|
542
542
|
return big(a).isEqualTo(big(b));
|
|
543
543
|
}
|
|
544
|
-
function
|
|
544
|
+
function bigGreaterThan(a, b) {
|
|
545
545
|
return big(a).isGreaterThan(big(b));
|
|
546
546
|
}
|
|
547
|
-
function
|
|
547
|
+
function bigGreaterThanOrEqualTo(a, b) {
|
|
548
548
|
return big(a).isGreaterThanOrEqualTo(big(b));
|
|
549
549
|
}
|
|
550
|
-
function
|
|
550
|
+
function bigLessThan(a, b) {
|
|
551
551
|
return big(a).isLessThan(big(b));
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function bigLessThanOrEqual(a, b) {
|
|
554
554
|
return big(a).isLessThanOrEqualTo(big(b));
|
|
555
555
|
}
|
|
556
556
|
|
|
@@ -7988,22 +7988,27 @@ function createTimeRandId(digits = 6) {
|
|
|
7988
7988
|
}
|
|
7989
7989
|
|
|
7990
7990
|
// src/ts/string/other.ts
|
|
7991
|
-
function
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
7991
|
+
function getByteLength(data) {
|
|
7992
|
+
if (typeof data === "string") {
|
|
7993
|
+
let byteLen = 0;
|
|
7994
|
+
for (let i = 0; i < data.length; i++) {
|
|
7995
|
+
const code = data.charCodeAt(i);
|
|
7996
|
+
if (code <= 127) {
|
|
7997
|
+
byteLen += 1;
|
|
7998
|
+
} else if (code <= 2047) {
|
|
7999
|
+
byteLen += 2;
|
|
8000
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
8001
|
+
byteLen += 4;
|
|
8002
|
+
i++;
|
|
8003
|
+
} else {
|
|
8004
|
+
byteLen += 3;
|
|
8005
|
+
}
|
|
8004
8006
|
}
|
|
8007
|
+
return byteLen;
|
|
8005
8008
|
}
|
|
8006
|
-
return
|
|
8009
|
+
if ("byteLength" in data) return data.byteLength;
|
|
8010
|
+
if ("size" in data) return data.size;
|
|
8011
|
+
throw new TypeError("getByteLength: Unsupported type");
|
|
8007
8012
|
}
|
|
8008
8013
|
|
|
8009
8014
|
// src/ts/url/file/index.ts
|
|
@@ -8581,18 +8586,19 @@ function isLongitude(s) {
|
|
|
8581
8586
|
attempt,
|
|
8582
8587
|
before,
|
|
8583
8588
|
big,
|
|
8584
|
-
bigAdd,
|
|
8585
8589
|
bigCompare,
|
|
8586
8590
|
bigDiv,
|
|
8587
8591
|
bigEqual,
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8592
|
+
bigFixed,
|
|
8593
|
+
bigGreaterThan,
|
|
8594
|
+
bigGreaterThanOrEqualTo,
|
|
8595
|
+
bigLessThan,
|
|
8596
|
+
bigLessThanOrEqual,
|
|
8597
|
+
bigMinus,
|
|
8598
|
+
bigPlus,
|
|
8593
8599
|
bigPow,
|
|
8594
8600
|
bigRound,
|
|
8595
|
-
|
|
8601
|
+
bigTimes,
|
|
8596
8602
|
bind,
|
|
8597
8603
|
bindAll,
|
|
8598
8604
|
bindKey,
|
|
@@ -8679,6 +8685,7 @@ function isLongitude(s) {
|
|
|
8679
8685
|
functionsIn,
|
|
8680
8686
|
get,
|
|
8681
8687
|
getAgeByBirthdate,
|
|
8688
|
+
getByteLength,
|
|
8682
8689
|
getCountdownParts,
|
|
8683
8690
|
getDateRangeAfter,
|
|
8684
8691
|
getDateRangeBefore,
|
|
@@ -8693,7 +8700,6 @@ function isLongitude(s) {
|
|
|
8693
8700
|
getQnHls,
|
|
8694
8701
|
getQnImg,
|
|
8695
8702
|
getQnVideo,
|
|
8696
|
-
getStringByteLength,
|
|
8697
8703
|
getUrlNumber,
|
|
8698
8704
|
getUrlParam,
|
|
8699
8705
|
getUrlParamAll,
|
|
@@ -8906,7 +8912,6 @@ function isLongitude(s) {
|
|
|
8906
8912
|
toChineseNum,
|
|
8907
8913
|
toDayjs,
|
|
8908
8914
|
toFinite,
|
|
8909
|
-
toFixed,
|
|
8910
8915
|
toInteger,
|
|
8911
8916
|
toIterator,
|
|
8912
8917
|
toJSON,
|