stronger typing

This commit is contained in:
2025-10-01 12:33:41 -04:00
parent 9c27981d24
commit caa473876a
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -30,8 +30,8 @@ local compressionModule = {} :: CompressionModule
@param opts Options table of type `types.opts` @param opts Options table of type `types.opts`
@return The decompressed data as a string, or false if decompression fails. @return The decompressed data as a string, or false if decompression fails.
]]-- ]]--
function compressionModule.zlibDecompress(contents: string, opts: types.opts): string | boolean function compressionModule.zlibDecompress(contents: string | buffer, opts: types.opts): string | boolean
assert(typeof(contents) == "string", "Expected contents to be of type 'string'") assert(typeof(contents) == "string" or typeof(contents) == "buffer", "Expected contents to be of type 'string' or 'buffer'")
assert(typeof(opts) == "table", "Expected opts to be of type 'table'") assert(typeof(opts) == "table", "Expected opts to be of type 'table'")
local success, decompressed: string = pcall(function() return serde.decompress("zlib", contents) end) local success, decompressed: string = pcall(function() return serde.decompress("zlib", contents) end)
if not success then if not success then
+1 -1
View File
@@ -11,7 +11,7 @@ function testFolder(callback: types.callbackFunction, opts: types.opts, folderPa
for _, file in pairs(folder) do for _, file in pairs(folder) do
local filePath = `./{folderPath}/{file}` local filePath = `./{folderPath}/{file}`
local fileContents = fs.readFile(filePath) local fileContents = fs.readFile(filePath)
local result = callback(fileContents, opts) local result = callback(fileContents, opts) :: boolean
results[file] = result results[file] = result
end end
return results return results