blob: 58833b1c8d8ab14243853e3ba6b7dd3d7f0dc112 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
-- Basic shim for LuaJIT's table.new and table.clear.
local has_new, new = pcall(require, 'table.new')
local has_clear, clear = pcall(require, 'table.clear')
local M = {}
if not has_new then
---@diagnostic disable-next-line: unused-local
new = function(narr, nrec)
return {}
end
end
if not has_clear then
clear = function(tab)
---@diagnostic disable-next-line: no-unknown
for k in pairs(tab) do
---@diagnostic disable-next-line: no-unknown
tab[k] = nil
end
end
end
M.new = new
M.clear = clear
return M
|