Skip to content

Commit d60951c

Browse files
feat: use size and time default transformers
1 parent 7184d14 commit d60951c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/rest-nvim/utils/init.lua

+7-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ local transform = {
532532
return time .. " " .. units[unit]
533533
end,
534534

535-
byte = function(bytes)
535+
size = function(bytes)
536536
bytes = tonumber(bytes)
537537

538538
local units = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" }
@@ -600,6 +600,12 @@ M.parse_statistics = function(body)
600600
if type(tbl.type) == "function" then
601601
value = tbl.type(value)
602602
end
603+
else
604+
for key, fun in pairs(transform) do
605+
if string.match(tbl[1], "^" .. key) then
606+
value = fun(value)
607+
end
608+
end
603609
end
604610

605611
table.insert(out, (tbl.title or (tbl[1] .. " ")) .. value)

0 commit comments

Comments
 (0)