aboutsummaryrefslogtreecommitdiffstats
path: root/util/human
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-06-03 19:46:17 +0200
committerKim Alvefur <zash@zash.se>2020-06-03 19:46:17 +0200
commitb95b0e602662861b8db5524d5e5971a927fb076f (patch)
treea21bf15c4b0f658148cf6fc3f60423a3afde5dc2 /util/human
parent509549f679bc6772bd36984d0f5ca056018d974d (diff)
downloadprosody-b95b0e602662861b8db5524d5e5971a927fb076f.tar.gz
prosody-b95b0e602662861b8db5524d5e5971a927fb076f.zip
util.human.units: Handle location of unpack() in Lua 5.1
Diffstat (limited to 'util/human')
-rw-r--r--util/human/units.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/human/units.lua b/util/human/units.lua
index 2c4662cd..91d6f0d5 100644
--- a/util/human/units.lua
+++ b/util/human/units.lua
@@ -1,3 +1,5 @@
+local unpack = table.unpack or unpack; --luacheck: ignore 113
+
local large = {
"k", 1000,
"M", 1000000,
@@ -49,7 +51,7 @@ local function format(n, unit, b) --> string
round = math.ceil;
end
local m = math.max(0, math.min(8, round(math.abs(math.log(math.abs(n), logbase)))));
- local prefix, multiplier = table.unpack(prefixes, m * 2-1, m*2);
+ local prefix, multiplier = unpack(prefixes, m * 2-1, m*2);
return fmt:format(n / (multiplier or 1), prefix or "", unit);
end