1 |
- {"ast":null,"code":"/* eslint-disable @typescript-eslint/naming-convention */\n/**\n * Checks for a matching suffix at the end of a string (for ES5 and lower)\n * @param str Source string\n * @param suffix Suffix to search for in the source string\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\n * @deprecated Please use native string function instead\n */\nexport const EndsWith = (str, suffix) => {\n return str.endsWith(suffix);\n};\n/**\n * Checks for a matching suffix at the beginning of a string (for ES5 and lower)\n * @param str Source string\n * @param suffix Suffix to search for in the source string\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\n * @deprecated Please use native string function instead\n */\nexport const StartsWith = (str, suffix) => {\n if (!str) {\n return false;\n }\n return str.startsWith(suffix);\n};\n/**\n * Decodes a buffer into a string\n * @param buffer The buffer to decode\n * @returns The decoded string\n */\nexport const Decode = buffer => {\n if (typeof TextDecoder !== \"undefined\") {\n return new TextDecoder().decode(buffer);\n }\n let result = \"\";\n for (let i = 0; i < buffer.byteLength; i++) {\n result += String.fromCharCode(buffer[i]);\n }\n return result;\n};\n/**\n * Encode a buffer to a base64 string\n * @param buffer defines the buffer to encode\n * @returns the encoded string\n */\nexport const EncodeArrayBufferToBase64 = buffer => {\n const keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n let output = \"\";\n let chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n let i = 0;\n const bytes = ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer);\n while (i < bytes.length) {\n chr1 = bytes[i++];\n chr2 = i < bytes.length ? bytes[i++] : Number.NaN;\n chr3 = i < bytes.length ? bytes[i++] : Number.NaN;\n enc1 = chr1 >> 2;\n enc2 = (chr1 & 3) << 4 | chr2 >> 4;\n enc3 = (chr2 & 15) << 2 | chr3 >> 6;\n enc4 = chr3 & 63;\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);\n }\n return output;\n};\n/**\n * Converts a given base64 string as an ASCII encoded stream of data\n * @param base64Data The base64 encoded string to decode\n * @returns Decoded ASCII string\n */\nexport const DecodeBase64ToString = base64Data => {\n return atob(base64Data);\n};\n/**\n * Converts a given base64 string into an ArrayBuffer of raw byte data\n * @param base64Data The base64 encoded string to decode\n * @returns ArrayBuffer of byte data\n */\nexport const DecodeBase64ToBinary = base64Data => {\n const decodedString = DecodeBase64ToString(base64Data);\n const bufferLength = decodedString.length;\n const bufferView = new Uint8Array(new ArrayBuffer(bufferLength));\n for (let i = 0; i < bufferLength; i++) {\n bufferView[i] = decodedString.charCodeAt(i);\n }\n return bufferView.buffer;\n};\n/**\n * Converts a number to string and pads with preceding zeroes until it is of specified length.\n * @param num the number to convert and pad\n * @param length the expected length of the string\n * @returns the padded string\n */\nexport const PadNumber = (num, length) => {\n let str = String(num);\n while (str.length < length) {\n str = \"0\" + str;\n }\n return str;\n};\n/**\n * Helper to manipulate strings\n */\nexport const StringTools = {\n EndsWith,\n StartsWith,\n Decode,\n EncodeArrayBufferToBase64,\n DecodeBase64ToString,\n DecodeBase64ToBinary,\n PadNumber\n};","map":{"version":3,"names":["EndsWith","str","suffix","endsWith","StartsWith","startsWith","Decode","buffer","TextDecoder","decode","result","i","byteLength","String","fromCharCode","EncodeArrayBufferToBase64","keyStr","output","chr1","chr2","chr3","enc1","enc2","enc3","enc4","bytes","ArrayBuffer","isView","Uint8Array","byteOffset","length","Number","NaN","isNaN","charAt","DecodeBase64ToString","base64Data","atob","DecodeBase64ToBinary","decodedString","bufferLength","bufferView","charCodeAt","PadNumber","num","StringTools"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Misc/stringTools.js"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/**\n * Checks for a matching suffix at the end of a string (for ES5 and lower)\n * @param str Source string\n * @param suffix Suffix to search for in the source string\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\n * @deprecated Please use native string function instead\n */\nexport const EndsWith = (str, suffix) => {\n return str.endsWith(suffix);\n};\n/**\n * Checks for a matching suffix at the beginning of a string (for ES5 and lower)\n * @param str Source string\n * @param suffix Suffix to search for in the source string\n * @returns Boolean indicating whether the suffix was found (true) or not (false)\n * @deprecated Please use native string function instead\n */\nexport const StartsWith = (str, suffix) => {\n if (!str) {\n return false;\n }\n return str.startsWith(suffix);\n};\n/**\n * Decodes a buffer into a string\n * @param buffer The buffer to decode\n * @returns The decoded string\n */\nexport const Decode = (buffer) => {\n if (typeof TextDecoder !== \"undefined\") {\n return new TextDecoder().decode(buffer);\n }\n let result = \"\";\n for (let i = 0; i < buffer.byteLength; i++) {\n result += String.fromCharCode(buffer[i]);\n }\n return result;\n};\n/**\n * Encode a buffer to a base64 string\n * @param buffer defines the buffer to encode\n * @returns the encoded string\n */\nexport const EncodeArrayBufferToBase64 = (buffer) => {\n const keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n let output = \"\";\n let chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n let i = 0;\n const bytes = ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer);\n while (i < bytes.length) {\n chr1 = bytes[i++];\n chr2 = i < bytes.length ? bytes[i++] : Number.NaN;\n chr3 = i < bytes.length ? bytes[i++] : Number.NaN;\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n }\n else if (isNaN(chr3)) {\n enc4 = 64;\n }\n output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);\n }\n return output;\n};\n/**\n * Converts a given base64 string as an ASCII encoded stream of data\n * @param base64Data The base64 encoded string to decode\n * @returns Decoded ASCII string\n */\nexport const DecodeBase64ToString = (base64Data) => {\n return atob(base64Data);\n};\n/**\n * Converts a given base64 string into an ArrayBuffer of raw byte data\n * @param base64Data The base64 encoded string to decode\n * @returns ArrayBuffer of byte data\n */\nexport const DecodeBase64ToBinary = (base64Data) => {\n const decodedString = DecodeBase64ToString(base64Data);\n const bufferLength = decodedString.length;\n const bufferView = new Uint8Array(new ArrayBuffer(bufferLength));\n for (let i = 0; i < bufferLength; i++) {\n bufferView[i] = decodedString.charCodeAt(i);\n }\n return bufferView.buffer;\n};\n/**\n * Converts a number to string and pads with preceding zeroes until it is of specified length.\n * @param num the number to convert and pad\n * @param length the expected length of the string\n * @returns the padded string\n */\nexport const PadNumber = (num, length) => {\n let str = String(num);\n while (str.length < length) {\n str = \"0\" + str;\n }\n return str;\n};\n/**\n * Helper to manipulate strings\n */\nexport const StringTools = {\n EndsWith,\n StartsWith,\n Decode,\n EncodeArrayBufferToBase64,\n DecodeBase64ToString,\n DecodeBase64ToBinary,\n PadNumber,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,QAAQ,GAAGA,CAACC,GAAG,EAAEC,MAAM,KAAK;EACrC,OAAOD,GAAG,CAACE,QAAQ,CAACD,MAAM,CAAC;AAC/B,CAAC;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,UAAU,GAAGA,CAACH,GAAG,EAAEC,MAAM,KAAK;EACvC,IAAI,CAACD,GAAG,EAAE;IACN,OAAO,KAAK;EAChB;EACA,OAAOA,GAAG,CAACI,UAAU,CAACH,MAAM,CAAC;AACjC,CAAC;AACD;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,MAAM,GAAIC,MAAM,IAAK;EAC9B,IAAI,OAAOC,WAAW,KAAK,WAAW,EAAE;IACpC,OAAO,IAAIA,WAAW,CAAC,CAAC,CAACC,MAAM,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