aboutsummaryrefslogtreecommitdiff
path: root/lua/api.lua
blob: b6495e064aa75740bae1c2127080c699c94e060e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
local function shallow_copy(t)
  local t2 = {}
  for k, v in pairs(t) do t2[k] = v end
  return t2
end

web.event.add_listener = function(events, opts)
  opts = shallow_copy(opts or {})
  if type(events) ~= "table" then events = { events } end
  opts.events = events or {}

  __internals.register_event(opts)
end