@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.
package/dist/index.js CHANGED
@@ -7547,22 +7547,27 @@ function createTimeRandId(digits = 6) {
7547
7547
  }
7548
7548
 
7549
7549
  // src/ts/string/other.ts
7550
- function getStringByteLength(str) {
7551
- let byteLen = 0;
7552
- for (let i = 0; i < str.length; i++) {
7553
- const code = str.charCodeAt(i);
7554
- if (code <= 127) {
7555
- byteLen += 1;
7556
- } else if (code <= 2047) {
7557
- byteLen += 2;
7558
- } else if (code >= 55296 && code <= 56319) {
7559
- byteLen += 4;
7560
- i++;
7561
- } else {
7562
- byteLen += 3;
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 byteLen;
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
@@ -8238,6 +8243,7 @@ export {
8238
8243
  functionsIn_default as functionsIn,
8239
8244
  get_default as get,
8240
8245
  getAgeByBirthdate,
8246
+ getByteLength,
8241
8247
  getCountdownParts,
8242
8248
  getDateRangeAfter,
8243
8249
  getDateRangeBefore,
@@ -8252,7 +8258,6 @@ export {
8252
8258
  getQnHls,
8253
8259
  getQnImg,
8254
8260
  getQnVideo,
8255
- getStringByteLength,
8256
8261
  getUrlNumber,
8257
8262
  getUrlParam,
8258
8263
  getUrlParamAll,