stronger typing
This commit is contained in:
@@ -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
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user