283283
284284--- 读取文件
285285--- @param path string
286+ --- @param keepBom ? boolean
287+ --- @return string ? text
288+ --- @return string ? errMsg
286289function m .loadFile (path , keepBom )
287290 local f , e = ioOpen (path , ' rb' )
288291 if not f then
308311--- 写入文件
309312--- @param path string
310313--- @param content string
314+ --- @return boolean ok
315+ --- @return string ? errMsg
311316function m .saveFile (path , content )
312317 local f , e = ioOpen (path , " wb" )
313318
357362--- 深拷贝(不处理元表)
358363--- @param source table
359364--- @param target ? table
365+ --- @return table
360366function m .deepCopy (source , target )
361367 local mark = {}
362368 local function copy (a , b )
@@ -379,6 +385,8 @@ function m.deepCopy(source, target)
379385end
380386
381387--- 序列化
388+ --- @param t table
389+ --- @return table
382390function m .unpack (t )
383391 local result = {}
384392 local tid = 0
@@ -406,6 +414,8 @@ function m.unpack(t)
406414end
407415
408416--- 反序列化
417+ --- @param t table
418+ --- @return table
409419function m .pack (t )
410420 local cache = {}
411421 local function pack (id )
@@ -733,6 +743,7 @@ function switchMT:has(name)
733743end
734744
735745--- @param name string
746+ --- @param ... any
736747--- @return ...
737748function switchMT :__call (name , ...)
738749 local callback = self .map [name ] or self ._default
@@ -752,6 +763,8 @@ function m.switch()
752763end
753764
754765--- @param f async fun ()
766+ --- @param name string
767+ --- @return any , boolean
755768function m .getUpvalue (f , name )
756769 for i = 1 , 999 do
757770 local uname , value = getupvalue (f , i )
819832
820833--- @param t table
821834--- @param sorter boolean | function
835+ --- @return any[]
822836function m .getTableKeys (t , sorter )
823837 local keys = {}
824838 for k in pairs (t ) do
0 commit comments