-- Compiled with roblox-ts v3.0.0 local TS = _G[script] local HttpService = TS.import(script, TS.getModule(script, "@rbxts", "services")).HttpService local FunctionTools = TS.import(script, script.Parent, "function_tools").FunctionTools local HttpTools = {} do local _container = HttpTools --[[ *removes lines with comments from the code * with them, cannot decode ]] local function RemoveJSONComments(json_code_text) local lines = string.split(json_code_text, "\n") -- ▼ ReadonlyArray.filter ▼ local _newValue = {} local _callback = function(value) --filters the // comments --allow if amount of comments on line is 0; return #{ string.match(value, "//") } == 0 end local _length = 0 for _k, _v in lines do if _callback(_v, _k - 1, lines) == true then _length += 1 _newValue[_length] = _v end end -- ▲ ReadonlyArray.filter ▲ local filtered_lines = _newValue --joines with the space; return table.concat(filtered_lines, " ") end _container.RemoveJSONComments = RemoveJSONComments --returns decoded data from HttpSerivce local function FetchJSONFromLink(link, remove_comments, warn_on_error) if remove_comments == nil then remove_comments = true end if warn_on_error == nil then warn_on_error = false end local success = true local result = nil TS.try(function() local raw_data = HttpService:GetAsync(link) --removes commands if remove_comments is true result = HttpService:JSONDecode(if remove_comments then RemoveJSONComments(raw_data) else raw_data) end, function(error) success = false if warn_on_error then warn(error) end end) return success, if success then result else nil end _container.FetchJSONFromLink = FetchJSONFromLink --[[ * * * @param domain domain url without / at the end ```https://lospec.com/``` * @param path path of the domain ```palette-list``` * @param default_parameters default values of the data that it can send * @returns async function thats returns data from the link and going to accept required data in form of a object and it's going to be encoded in url ]] local function ConstructGetRequest(domain, path, default_parameters) local url = `{domain}/{path}` if default_parameters == nil then return TS.async(function() return HttpService:GetAsync(url) end) end local SetParameters = TS.async(function(data) local data_map = data local index = 0 local parameters = "" -- ▼ ReadonlyMap.forEach ▼ local _callback = function(value, key) --checks if it's a first parameter and add ?, otherwise will add & before local prefix = if index == 0 then "?" else "&" index += 1 parameters ..= `{prefix}{value}={tostring(key)}` end for _k, _v in data_map do _callback(_v, _k, data_map) end -- ▲ ReadonlyMap.forEach ▲ return HttpService:GetAsync(url .. parameters) end) return FunctionTools.CreateFunctionWithOptionalArguments(default_parameters, SetParameters) end _container.ConstructGetRequest = ConstructGetRequest end return { HttpTools = HttpTools, }