108 lines
2.7 KiB
JavaScript
108 lines
2.7 KiB
JavaScript
// Metro module 581 (f582).
|
|
const Emitter = function Emitter(a0) {
|
|
if (a0) {
|
|
const prototype = Emitter.prototype;
|
|
for (const key in prototype) {
|
|
a0[key] = Emitter.prototype[key];
|
|
}
|
|
return a0;
|
|
}
|
|
};
|
|
if (module !== void 0) {
|
|
module.exports = Emitter;
|
|
}
|
|
const { prototype: prototype4, prototype } = Emitter;
|
|
const addEventListener2 = function(a0, a1) {
|
|
this._callbacks = this._callbacks || {};
|
|
const _callbacks = this._callbacks;
|
|
const r6 = "$" + a0;
|
|
const r8 = this._callbacks["$" + a0] || [];
|
|
_callbacks[r6] = r8;
|
|
r8.push(a1);
|
|
return this;
|
|
};
|
|
prototype.addEventListener = addEventListener2;
|
|
prototype4.on = addEventListener2;
|
|
Emitter.prototype.once = function(a0, a1) {
|
|
const on2 = function on() {
|
|
this.off(a0, on2);
|
|
a1.apply(this, arguments);
|
|
};
|
|
on2.fn = a1;
|
|
this.on(a0, on2);
|
|
return this;
|
|
};
|
|
const { prototype: prototype5, prototype: prototype6, prototype: prototype2, prototype: prototype3 } = Emitter;
|
|
const removeEventListener = function(a0, a1) {
|
|
this._callbacks = this._callbacks || {};
|
|
if (arguments.length == 0) {
|
|
this._callbacks = {};
|
|
return this;
|
|
}
|
|
const r16 = this._callbacks["$" + a0];
|
|
if (r16) {
|
|
if (arguments.length == 1) {
|
|
delete this._callbacks["$" + a0];
|
|
return this;
|
|
}
|
|
const r5 = 0 < r16.length;
|
|
let r0 = 0;
|
|
if (r5) {
|
|
while (true) {
|
|
const r19 = r16[r0];
|
|
const r1 = r0;
|
|
if (r19 !== a1 && r19.fn !== a1) {
|
|
r0 = r1 + 1;
|
|
if (r0 < r16.length) {
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
r16.splice(r1, 1);
|
|
break;
|
|
}
|
|
}
|
|
if (r16.length === 0) {
|
|
delete this._callbacks["$" + a0];
|
|
}
|
|
return this;
|
|
}
|
|
return this;
|
|
};
|
|
prototype3.removeEventListener = removeEventListener;
|
|
prototype2.removeAllListeners = removeEventListener;
|
|
prototype6.removeListener = removeEventListener;
|
|
prototype5.off = removeEventListener;
|
|
Emitter.prototype.emit = function(a0) {
|
|
this._callbacks = this._callbacks || {};
|
|
const array = new Array(arguments.length - 1);
|
|
const r21 = this._callbacks["$" + a0];
|
|
const r3 = 1 < arguments.length;
|
|
let r0 = 1;
|
|
if (r3) {
|
|
do {
|
|
array[r0 - 1] = arguments[r0];
|
|
r0 = r0 + 1;
|
|
} while (r0 < arguments.length);
|
|
}
|
|
if (r21) {
|
|
let r28 = 0;
|
|
const r29 = r21.slice(0);
|
|
const length = r29.length;
|
|
if (0 < length) {
|
|
do {
|
|
r29[r28].apply(this, array);
|
|
r28 = r28 + 1;
|
|
} while (r28 < length);
|
|
}
|
|
}
|
|
return this;
|
|
};
|
|
Emitter.prototype.listeners = function(a0) {
|
|
this._callbacks = this._callbacks || {};
|
|
return this._callbacks["$" + a0] || [];
|
|
};
|
|
Emitter.prototype.hasListeners = function(a0) {
|
|
return !!this.listeners(a0).length;
|
|
};
|