@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.
@@ -823,6 +823,7 @@ var baseToolsTS = (() => {
823
823
  functionsIn: () => functionsIn_default,
824
824
  get: () => get_default,
825
825
  getAgeByBirthdate: () => getAgeByBirthdate,
826
+ getByteLength: () => getByteLength,
826
827
  getCountdownParts: () => getCountdownParts,
827
828
  getDateRangeAfter: () => getDateRangeAfter,
828
829
  getDateRangeBefore: () => getDateRangeBefore,
@@ -837,7 +838,6 @@ var baseToolsTS = (() => {
837
838
  getQnHls: () => getQnHls,
838
839
  getQnImg: () => getQnImg,
839
840
  getQnVideo: () => getQnVideo,
840
- getStringByteLength: () => getStringByteLength,
841
841
  getUrlNumber: () => getUrlNumber,
842
842
  getUrlParam: () => getUrlParam,
843
843
  getUrlParamAll: () => getUrlParamAll,
@@ -10026,22 +10026,27 @@ var baseToolsTS = (() => {
10026
10026
  }
10027
10027
 
10028
10028
  // src/ts/string/other.ts
10029
- function getStringByteLength(str) {
10030
- let byteLen = 0;
10031
- for (let i = 0; i < str.length; i++) {
10032
- const code = str.charCodeAt(i);
10033
- if (code <= 127) {
10034
- byteLen += 1;
10035
- } else if (code <= 2047) {
10036
- byteLen += 2;
10037
- } else if (code >= 55296 && code <= 56319) {
10038
- byteLen += 4;
10039
- i++;
10040
- } else {
10041
- byteLen += 3;
10029
+ function getByteLength(data) {
10030
+ if (typeof data === "string") {
10031
+ let byteLen = 0;
10032
+ for (let i = 0; i < data.length; i++) {
10033
+ const code = data.charCodeAt(i);
10034
+ if (code <= 127) {
10035
+ byteLen += 1;
10036
+ } else if (code <= 2047) {
10037
+ byteLen += 2;
10038
+ } else if (code >= 55296 && code <= 56319) {
10039
+ byteLen += 4;
10040
+ i++;
10041
+ } else {
10042
+ byteLen += 3;
10043
+ }
10042
10044
  }
10045
+ return byteLen;
10043
10046
  }
10044
- return byteLen;
10047
+ if ("byteLength" in data) return data.byteLength;
10048
+ if ("size" in data) return data.size;
10049
+ throw new TypeError("getByteLength: Unsupported type");
10045
10050
  }
10046
10051
 
10047
10052
  // src/ts/url/file/index.ts