Changeset

10888:42a0d9089de9

util.human.units: Handle location of unpack() in Lua 5.1
author Kim Alvefur <zash@zash.se>
date Wed, 03 Jun 2020 19:46:17 +0200
parents 10887:3debe04a6162
children 10889:25e0ec11b4e4
files util/human/units.lua
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/util/human/units.lua	Wed Jun 03 19:27:44 2020 +0200
+++ b/util/human/units.lua	Wed Jun 03 19:46:17 2020 +0200
@@ -1,3 +1,5 @@
+local unpack = table.unpack or unpack; --luacheck: ignore 113
+
 local large = {
 	"k", 1000,
 	"M", 1000000,
@@ -49,7 +51,7 @@
 		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