Mercurial Hosting > chat
diff src/lib/Utils.luan @ 17:7230c821c368
push fixes
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 Nov 2024 14:44:35 -0700 |
parents | 2da10ece826f |
children | 7ea33179592a |
line wrap: on
line diff
--- a/src/lib/Utils.luan Sun Nov 03 21:22:06 2024 -0700 +++ b/src/lib/Utils.luan Mon Nov 04 14:44:35 2024 -0700 @@ -2,6 +2,7 @@ local error = Luan.error local type = Luan.type or error() local ipairs = Luan.ipairs or error() +local pairs = Luan.pairs or error() local set_metatable = Luan.set_metatable or error() local Http = require "luan:http/Http.luan" @@ -48,4 +49,23 @@ end end +function Utils.set_to_list(set) + local list = {} + for k, v in pairs(set) do + if v then + list[#list+1] = k + end + end + return list +end + +function Utils.is_in_list(el,list) + for _, v in ipairs(list) do + if v == el then + return true + end + end + return false +end + return Utils