Skip to content

Commit 6dad1ca

Browse files
committed
Update polyfills
1 parent d69141e commit 6dad1ca

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/prometheus.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212
local oldPkgPath = package.path;
1313
package.path = script_path() .. "?.lua;" .. package.path;
1414

15-
-- Math.random Fix
15+
-- Math.random Fix for Lua5.1
1616
-- Check if fix is needed
1717
if not pcall(function()
1818
return math.random(1, 2^40);
@@ -38,6 +38,14 @@ end) then
3838
end
3939
end
4040

41+
-- newproxy polyfill
42+
_G.newproxy = _G.newproxy or function(arg)
43+
if arg then
44+
return setmetatable({}, {});
45+
end
46+
return {};
47+
end
48+
4149

4250
-- Require Prometheus Submodules
4351
local Pipeline = require("prometheus.pipeline");

src/prometheus/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ end
243243

244244

245245
local function readonly(obj)
246-
local r = newproxy and newproxy(true) or setmetatable({}, {});
246+
local r = newproxy(true);
247247
getmetatable(r).__index = obj;
248248
return r;
249249
end

0 commit comments

Comments
 (0)