stronger typing
This commit is contained in:
@@ -30,8 +30,8 @@ local compressionModule = {} :: CompressionModule
|
||||
@param opts Options table of type `types.opts`
|
||||
@return The decompressed data as a string, or false if decompression fails.
|
||||
]]--
|
||||
function compressionModule.zlibDecompress(contents: string, opts: types.opts): string | boolean
|
||||
assert(typeof(contents) == "string", "Expected contents to be of type 'string'")
|
||||
function compressionModule.zlibDecompress(contents: string | buffer, opts: types.opts): string | boolean
|
||||
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'")
|
||||
local success, decompressed: string = pcall(function() return serde.decompress("zlib", contents) end)
|
||||
if not success then
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ function testFolder(callback: types.callbackFunction, opts: types.opts, folderPa
|
||||
for _, file in pairs(folder) do
|
||||
local filePath = `./{folderPath}/{file}`
|
||||
local fileContents = fs.readFile(filePath)
|
||||
local result = callback(fileContents, opts)
|
||||
local result = callback(fileContents, opts) :: boolean
|
||||
results[file] = result
|
||||
end
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user