@base-web-kits/base-tools-ts 0.9.10 → 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.
@@ -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: '01', h: '02', m: '03', s: '04', ms: '567' }
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/index.cjs CHANGED
@@ -144,6 +144,7 @@ __export(index_exports, {
144
144
  functionsIn: () => functionsIn_default,
145
145
  get: () => get_default,
146
146
  getAgeByBirthdate: () => getAgeByBirthdate,
147
+ getByteLength: () => getByteLength,
147
148
  getCountdownParts: () => getCountdownParts,
148
149
  getDateRangeAfter: () => getDateRangeAfter,
149
150
  getDateRangeBefore: () => getDateRangeBefore,
@@ -158,7 +159,6 @@ __export(index_exports, {
158
159
  getQnHls: () => getQnHls,
159
160
  getQnImg: () => getQnImg,
160
161
  getQnVideo: () => getQnVideo,
161
- getStringByteLength: () => getStringByteLength,
162
162
  getUrlNumber: () => getUrlNumber,
163
163
  getUrlParam: () => getUrlParam,
164
164
  getUrlParamAll: () => getUrlParamAll,
@@ -7988,22 +7988,27 @@ function createTimeRandId(digits = 6) {
7988
7988
  }
7989
7989
 
7990
7990
  // src/ts/string/other.ts
7991
- function getStringByteLength(str) {
7992
- let byteLen = 0;
7993
- for (let i = 0; i < str.length; i++) {
7994
- const code = str.charCodeAt(i);
7995
- if (code <= 127) {
7996
- byteLen += 1;
7997
- } else if (code <= 2047) {
7998
- byteLen += 2;
7999
- } else if (code >= 55296 && code <= 56319) {
8000
- byteLen += 4;
8001
- i++;
8002
- } else {
8003
- byteLen += 3;
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 byteLen;
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
@@ -8680,6 +8685,7 @@ function isLongitude(s) {
8680
8685
  functionsIn,
8681
8686
  get,
8682
8687
  getAgeByBirthdate,
8688
+ getByteLength,
8683
8689
  getCountdownParts,
8684
8690
  getDateRangeAfter,
8685
8691
  getDateRangeBefore,
@@ -8694,7 +8700,6 @@ function isLongitude(s) {
8694
8700
  getQnHls,
8695
8701
  getQnImg,
8696
8702
  getQnVideo,
8697
- getStringByteLength,
8698
8703
  getUrlNumber,
8699
8704
  getUrlParam,
8700
8705
  getUrlParamAll,