@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/index.js
CHANGED
|
@@ -65,24 +65,24 @@ import BigNumber from "bignumber.js";
|
|
|
65
65
|
function big(x) {
|
|
66
66
|
return x instanceof BigNumber ? x : new BigNumber(x);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
let acc = big(
|
|
70
|
-
for (const x of rest2) acc = acc.plus(big(x));
|
|
68
|
+
function bigPlus(...rest2) {
|
|
69
|
+
let acc = big(rest2[0]);
|
|
70
|
+
for (const x of rest2.slice(1)) acc = acc.plus(big(x));
|
|
71
71
|
return acc.toNumber();
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
let acc = big(
|
|
75
|
-
for (const x of rest2) acc = acc.minus(big(x));
|
|
73
|
+
function bigMinus(...rest2) {
|
|
74
|
+
let acc = big(rest2[0]);
|
|
75
|
+
for (const x of rest2.slice(1)) acc = acc.minus(big(x));
|
|
76
76
|
return acc.toNumber();
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
let acc = big(
|
|
80
|
-
for (const x of rest2) acc = acc.times(big(x));
|
|
78
|
+
function bigTimes(...rest2) {
|
|
79
|
+
let acc = big(rest2[0]);
|
|
80
|
+
for (const x of rest2.slice(1)) acc = acc.times(big(x));
|
|
81
81
|
return acc.toNumber();
|
|
82
82
|
}
|
|
83
|
-
function bigDiv(
|
|
84
|
-
let acc = big(
|
|
85
|
-
for (const x of rest2) acc = acc.div(big(x));
|
|
83
|
+
function bigDiv(...rest2) {
|
|
84
|
+
let acc = big(rest2[0]);
|
|
85
|
+
for (const x of rest2.slice(1)) acc = acc.div(big(x));
|
|
86
86
|
return acc.toNumber();
|
|
87
87
|
}
|
|
88
88
|
function bigPow(x, y) {
|
|
@@ -91,7 +91,7 @@ function bigPow(x, y) {
|
|
|
91
91
|
function bigRound(x, dp = 0, rm = BigNumber.ROUND_HALF_UP) {
|
|
92
92
|
return big(x).decimalPlaces(dp, rm).toNumber();
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function bigFixed(x, dp = 2, rm = BigNumber.ROUND_HALF_UP) {
|
|
95
95
|
return big(x).toFixed(dp, rm);
|
|
96
96
|
}
|
|
97
97
|
function bigCompare(a, b) {
|
|
@@ -100,16 +100,16 @@ function bigCompare(a, b) {
|
|
|
100
100
|
function bigEqual(a, b) {
|
|
101
101
|
return big(a).isEqualTo(big(b));
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function bigGreaterThan(a, b) {
|
|
104
104
|
return big(a).isGreaterThan(big(b));
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function bigGreaterThanOrEqualTo(a, b) {
|
|
107
107
|
return big(a).isGreaterThanOrEqualTo(big(b));
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function bigLessThan(a, b) {
|
|
110
110
|
return big(a).isLessThan(big(b));
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function bigLessThanOrEqual(a, b) {
|
|
113
113
|
return big(a).isLessThanOrEqualTo(big(b));
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -7547,22 +7547,27 @@ function createTimeRandId(digits = 6) {
|
|
|
7547
7547
|
}
|
|
7548
7548
|
|
|
7549
7549
|
// src/ts/string/other.ts
|
|
7550
|
-
function
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7550
|
+
function getByteLength(data) {
|
|
7551
|
+
if (typeof data === "string") {
|
|
7552
|
+
let byteLen = 0;
|
|
7553
|
+
for (let i = 0; i < data.length; i++) {
|
|
7554
|
+
const code = data.charCodeAt(i);
|
|
7555
|
+
if (code <= 127) {
|
|
7556
|
+
byteLen += 1;
|
|
7557
|
+
} else if (code <= 2047) {
|
|
7558
|
+
byteLen += 2;
|
|
7559
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
7560
|
+
byteLen += 4;
|
|
7561
|
+
i++;
|
|
7562
|
+
} else {
|
|
7563
|
+
byteLen += 3;
|
|
7564
|
+
}
|
|
7563
7565
|
}
|
|
7566
|
+
return byteLen;
|
|
7564
7567
|
}
|
|
7565
|
-
return
|
|
7568
|
+
if ("byteLength" in data) return data.byteLength;
|
|
7569
|
+
if ("size" in data) return data.size;
|
|
7570
|
+
throw new TypeError("getByteLength: Unsupported type");
|
|
7566
7571
|
}
|
|
7567
7572
|
|
|
7568
7573
|
// src/ts/url/file/index.ts
|
|
@@ -8139,18 +8144,19 @@ export {
|
|
|
8139
8144
|
attempt_default as attempt,
|
|
8140
8145
|
before_default as before,
|
|
8141
8146
|
big,
|
|
8142
|
-
bigAdd,
|
|
8143
8147
|
bigCompare,
|
|
8144
8148
|
bigDiv,
|
|
8145
8149
|
bigEqual,
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8150
|
+
bigFixed,
|
|
8151
|
+
bigGreaterThan,
|
|
8152
|
+
bigGreaterThanOrEqualTo,
|
|
8153
|
+
bigLessThan,
|
|
8154
|
+
bigLessThanOrEqual,
|
|
8155
|
+
bigMinus,
|
|
8156
|
+
bigPlus,
|
|
8151
8157
|
bigPow,
|
|
8152
8158
|
bigRound,
|
|
8153
|
-
|
|
8159
|
+
bigTimes,
|
|
8154
8160
|
bind_default as bind,
|
|
8155
8161
|
bindAll_default as bindAll,
|
|
8156
8162
|
bindKey_default as bindKey,
|
|
@@ -8237,6 +8243,7 @@ export {
|
|
|
8237
8243
|
functionsIn_default as functionsIn,
|
|
8238
8244
|
get_default as get,
|
|
8239
8245
|
getAgeByBirthdate,
|
|
8246
|
+
getByteLength,
|
|
8240
8247
|
getCountdownParts,
|
|
8241
8248
|
getDateRangeAfter,
|
|
8242
8249
|
getDateRangeBefore,
|
|
@@ -8251,7 +8258,6 @@ export {
|
|
|
8251
8258
|
getQnHls,
|
|
8252
8259
|
getQnImg,
|
|
8253
8260
|
getQnVideo,
|
|
8254
|
-
getStringByteLength,
|
|
8255
8261
|
getUrlNumber,
|
|
8256
8262
|
getUrlParam,
|
|
8257
8263
|
getUrlParamAll,
|
|
@@ -8464,7 +8470,6 @@ export {
|
|
|
8464
8470
|
toChineseNum,
|
|
8465
8471
|
toDayjs,
|
|
8466
8472
|
toFinite_default as toFinite,
|
|
8467
|
-
toFixed,
|
|
8468
8473
|
toInteger_default as toInteger,
|
|
8469
8474
|
toIterator_default as toIterator,
|
|
8470
8475
|
wrapperValue_default as toJSON,
|