Mercurial Hosting > lang
comparison src/lib/Utils.luan @ 39:df72d5d5d9dc
add cache_control
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 10 Aug 2025 06:25:35 +0900 |
parents | d34d709a7a8e |
children | cc20eebaa74a |
comparison
equal
deleted
inserted
replaced
38:238a91f224b1 | 39:df72d5d5d9dc |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local pairs = Luan.pairs or error() | 3 local pairs = Luan.pairs or error() |
4 local type = Luan.type or error() | |
4 local Http = require "luan:http/Http.luan" | 5 local Http = require "luan:http/Http.luan" |
5 | 6 |
6 | 7 |
7 local Utils = {} | 8 local Utils = {} |
8 | 9 |
17 rtn[key] = val | 18 rtn[key] = val |
18 end | 19 end |
19 return rtn | 20 return rtn |
20 end | 21 end |
21 | 22 |
23 local function deep_copy2(v,map) | |
24 if type(v) ~= "table" then | |
25 return v | |
26 end | |
27 local v2 = map[v] | |
28 if v2 ~= nil then | |
29 return v2 | |
30 end | |
31 local t = {} | |
32 map[v] = t | |
33 for key, val in pairs(v) do | |
34 t[deep_copy2(key,map)] = deep_copy2(val,map) | |
35 end | |
36 return t | |
37 end | |
38 | |
39 local function deep_copy(v) | |
40 return deep_copy2(v,{}) | |
41 end | |
42 Utils.deep_copy = deep_copy | |
43 | |
22 --[[ | 44 --[[ |
23 function Utils.get_first(t) | 45 function Utils.get_first(t) |
24 return pairs(t)() | 46 return pairs(t)() |
25 end | 47 end |
26 ]] | 48 ]] |