1
0
Fork 0
Agora-Miniapp-Tutorial/utils/event.js

1 line
462 B
JavaScript
Executable File

module.exports = function (n) { var t = {}, e = []; n = n || this, n.on = function (e, r, l) { return (t[e] = t[e] || []).push([r, l]), n }, n.off = function (r, l) { r || (t = {}); for (var o = t[r] || e, u = o.length = l ? o.length : 0; u--;)l == o[u][0] && o.splice(u, 1); return n }, n.emit = function (r) { for (var l, o = t[r] || e, u = o.length > 0 ? o.slice(0, o.length) : o, i = 0; l = u[i++];)l[0].apply(l[1], e.slice.call(arguments, 1)); return n } };