mirror of
https://github.com/0x5eal/terracotta.git
synced 2024-12-12 12:50:35 +00:00
20 lines
No EOL
542 B
Text
20 lines
No EOL
542 B
Text
local _Net = require("@lune/net")
|
|
local JSONEncode, JSONDecode = _Net.jsonEncode, _Net.jsonDecode
|
|
|
|
local MiscUtils = {}
|
|
|
|
function MiscUtils.Format(formatStr: string, with: {[string]: string})
|
|
return table.pack(string.gsub(formatStr, "\$\{(%a+)\}", function(s)
|
|
return with[s] or ""
|
|
end))[1]
|
|
end
|
|
|
|
function MiscUtils.PrettifyJson(json: string | {[any]: any}): string
|
|
if typeof(json) == "table" then
|
|
return JSONEncode(json, true)
|
|
else
|
|
return JSONEncode(JSONDecode(json), true)
|
|
end
|
|
end
|
|
|
|
return MiscUtils |