From 8a2a9c429edca91d9dc8f2c0c09b4a3b8049bbbd Mon Sep 17 00:00:00 2001 From: MH4GF Date: Thu, 19 Dec 2024 20:03:35 +0900 Subject: [PATCH] chore: translate to English --- .../erd-core/src/utils/compressionString.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/packages/erd-core/src/utils/compressionString.ts b/frontend/packages/erd-core/src/utils/compressionString.ts index beaab9f5..b7d2f04a 100644 --- a/frontend/packages/erd-core/src/utils/compressionString.ts +++ b/frontend/packages/erd-core/src/utils/compressionString.ts @@ -13,54 +13,54 @@ export async function compressToUTF16(input: string): Promise { const encoder = new TextEncoder() const inputBytes = encoder.encode(input) - // Deflate圧縮 + // Deflate compression const compressionStream = new CompressionStream('deflate') const compressedStream = createReadableStreamFromBytes(inputBytes).pipeThrough(compressionStream) const compressedBuffer = await new Response(compressedStream).arrayBuffer() const compressedBytes = new Uint8Array(compressedBuffer) - // 圧縮後のバイト長を格納するため、先頭4バイトに長さ情報を入れる + // Store the length of the compressed bytes in the first 4 bytes const length = compressedBytes.length - const totalLength = 4 + length // 最初の4バイトで長さを格納 - // 2バイト(UTF-16コードユニット)境界に揃えるため、必要なら1バイトパディング + const totalLength = 4 + length // Store length in the first 4 bytes + // Align to 2-byte (UTF-16 code unit) boundary, add 1 byte padding if necessary const paddedLength = totalLength % 2 === 0 ? totalLength : totalLength + 1 const resultBytes = new Uint8Array(paddedLength) const dataView = new DataView(resultBytes.buffer) - // 先頭4バイトに長さ情報を格納 (Little Endian) + // Store length information in the first 4 bytes (Little Endian) dataView.setUint32(0, length, true) - // その後に圧縮データ本体を格納 + // Store the compressed data after the first 4 bytes resultBytes.set(compressedBytes, 4) - // UTF-16コードユニットとして解釈するためにUint16Arrayに変換 + // Convert to Uint16Array to interpret as UTF-16 code units const uint16Array = new Uint16Array(resultBytes.buffer) - // 各Uint16要素をコードユニットとして文字列化 + // Convert each Uint16 element to a character return String.fromCharCode(...Array.from(uint16Array)) } export async function decompressFromUTF16(input: string): Promise { const decoder = new TextDecoder() - // UTF-16コードユニット列をUint16Arrayとして再構成 + // Reconstruct Uint16Array from UTF-16 code units const codeUnits = new Uint16Array(input.length) for (let i = 0; i < input.length; i++) { codeUnits[i] = input.charCodeAt(i) } - // Uint16ArrayからUint8Arrayを参照取得 + // Reference Uint8Array from Uint16Array const bytes = new Uint8Array(codeUnits.buffer) const dataView = new DataView(bytes.buffer) - // 先頭4バイトから圧縮データの実際の長さを取得 + // Get the actual length of the compressed data from the first 4 bytes const length = dataView.getUint32(0, true) - // 圧縮データ部分を切り出し + // Extract the compressed data part const compressedBytes = bytes.subarray(4, 4 + length) - // 解凍 + // Decompress const decompressionStream = new DecompressionStream('deflate') const decompressedStream = createReadableStreamFromBytes(compressedBytes).pipeThrough(