几个table相关函数独立成TABLE模块
This commit is contained in:
@@ -15,7 +15,7 @@ DUMPTABLE=require"Zframework/dumpTable"
|
||||
URLENCODE=require"Zframework/urlEncode"
|
||||
|
||||
-- UPPERCHAR=require"Zframework/upperChar"
|
||||
require"Zframework/copyTable"
|
||||
TABLE=require"Zframework/tableExtend"
|
||||
SPLITSTR=require"Zframework/splitStr"
|
||||
TIMESTR=require"Zframework/timeStr"
|
||||
|
||||
|
||||
@@ -1,42 +1,45 @@
|
||||
function copyList(org)
|
||||
local type=type
|
||||
local TABLE={}
|
||||
function TABLE.shift(org)
|
||||
local L={}
|
||||
for i=1,#org do
|
||||
if type(org[i])~="table"then
|
||||
L[i]=org[i]
|
||||
else
|
||||
L[i]=copyList(org[i])
|
||||
L[i]=TABLE.shift(org[i])
|
||||
end
|
||||
end
|
||||
return L
|
||||
end
|
||||
function copyTable(org)
|
||||
function TABLE.copy(org)
|
||||
local L={}
|
||||
for k,v in next,org do
|
||||
if type(v)~="table"then
|
||||
L[k]=v
|
||||
else
|
||||
L[k]=copyTable(v)
|
||||
L[k]=TABLE.copy(v)
|
||||
end
|
||||
end
|
||||
return L
|
||||
end
|
||||
function addToTable(G,base)--For all things in G if same type in base, push to base
|
||||
function TABLE.add(G,base)--For all things in G if same type in base, push to base
|
||||
for k,v in next,G do
|
||||
if type(v)==type(base[k])then
|
||||
if type(v)=="table"then
|
||||
addToTable(v,base[k])
|
||||
TABLE.add(v,base[k])
|
||||
else
|
||||
base[k]=v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function completeTable(G,base)--For all things in G if no val in base, push to base
|
||||
function TABLE.complete(G,base)--For all things in G if no val in base, push to base
|
||||
for k,v in next,G do
|
||||
if base[k]==nil then
|
||||
base[k]=v
|
||||
elseif type(v)=="table"and type(base[k])=="table"then
|
||||
completeTable(v,base[k])
|
||||
TABLE.complete(v,base[k])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return TABLE
|
||||
@@ -4,8 +4,8 @@ local path="/tech/socket/v1"
|
||||
|
||||
local wsThread=[[
|
||||
-- lua + love2d threading websocket client
|
||||
-- original pure lua ver. by flaribbit and Particle_G and MrZ_26
|
||||
-- threading version by MrZ_26
|
||||
-- Original pure lua ver. by flaribbit and Particle_G and MrZ
|
||||
-- Threading version by MrZ
|
||||
|
||||
local triggerCHN,sendCHN,readCHN=...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user