style: apply stylua formatter

This commit is contained in:
Erica Marigold 2025-01-06 06:19:29 +00:00
parent 48a66800b7
commit ecb63a0e2d
Signed by: DevComp
GPG key ID: 429EF1C337871656

View file

@ -33,28 +33,29 @@ local function validateCrc(decompressed: buffer, validation: CrcValidationOption
end end
export type CompressionMethod = "STORE" | "DEFLATE" export type CompressionMethod = "STORE" | "DEFLATE"
local DECOMPRESSION_ROUTINES: { [number]: { name: CompressionMethod, decompress: (buffer, number, CrcValidationOptions) -> buffer } } = table.freeze({ local DECOMPRESSION_ROUTINES: { [number]: { name: CompressionMethod, decompress: (buffer, number, CrcValidationOptions) -> buffer } } =
-- `STORE` decompression method - No compression table.freeze({
[0x00] = { -- `STORE` decompression method - No compression
name = "STORE" :: CompressionMethod, [0x00] = {
decompress = function(buf, _, validation) name = "STORE" :: CompressionMethod,
validateCrc(buf, validation) decompress = function(buf, _, validation)
return buf validateCrc(buf, validation)
end return buf
}, end,
},
-- `DEFLATE` decompression method - Compressed raw deflate chunks -- `DEFLATE` decompression method - Compressed raw deflate chunks
[0x08] = { [0x08] = {
name = "DEFLATE" :: CompressionMethod, name = "DEFLATE" :: CompressionMethod,
decompress = function(buf, uncompressedSize, validation) decompress = function(buf, uncompressedSize, validation)
-- FIXME: Why is uncompressedSize not getting inferred correctly although it -- FIXME: Why is uncompressedSize not getting inferred correctly although it
-- is typed? -- is typed?
local decompressed = inflate(buf, uncompressedSize :: any) local decompressed = inflate(buf, uncompressedSize :: any)
validateCrc(decompressed, validation) validateCrc(decompressed, validation)
return decompressed return decompressed
end end,
}, },
}) })
-- TODO: ERROR HANDLING! -- TODO: ERROR HANDLING!
@ -73,14 +74,21 @@ type ZipEntryInner = {
children: { ZipEntry }, -- The children of the entry children: { ZipEntry }, -- The children of the entry
} }
function ZipEntry.new(name: string, size: number, offset: number, timestamp: number, method: CompressionMethod?, crc: number): ZipEntry function ZipEntry.new(
name: string,
size: number,
offset: number,
timestamp: number,
method: CompressionMethod?,
crc: number
): ZipEntry
return setmetatable( return setmetatable(
{ {
name = name, name = name,
size = size, size = size,
offset = offset, offset = offset,
timestamp = timestamp, timestamp = timestamp,
method = method, method = method,
crc = crc, crc = crc,
isDirectory = string.sub(name, -1) == "/", isDirectory = string.sub(name, -1) == "/",
parent = nil, parent = nil,