diff src/lib/Shared.luan @ 13:24668255cede

preprocess urls
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 Jul 2022 23:59:41 -0600
parents 0472897e790d
children 3ea49246d6a7
line wrap: on
line diff
--- a/src/lib/Shared.luan	Sun Jul 03 22:01:23 2022 -0600
+++ b/src/lib/Shared.luan	Sun Jul 03 23:59:41 2022 -0600
@@ -1,5 +1,7 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
+local ipairs = Luan.ipairs or error()
+local set_metatable = Luan.set_metatable or error()
 local Http = require "luan:http/Http.luan"
 local Io = require "luan:Io.luan"
 local uri = Io.uri or error()
@@ -69,4 +71,18 @@
 	return json_parse(response)
 end
 
+local set_mt = {}
+function set_mt.__index(table,key)
+	return false
+end
+
+function Shared.list_to_set(list)
+	local set = {}
+	for _, v in ipairs(list) do
+		set[v] = true
+	end
+	set_metatable(set,set_mt)
+	return set
+end
+
 return Shared