decord/source/581_Emitter.js

134 lines
3.1 KiB
JavaScript
Raw Normal View History

2026-07-29 08:29:29 +00:00
// Module ID: 581
// Function ID: 582
2026-07-20 16:05:17 +00:00
// Name: Emitter
// Dependencies: []
2026-07-29 08:29:29 +00:00
// Module 581 (Emitter)
2026-07-20 16:05:17 +00:00
class Emitter {
constructor(arg0) {
if (global) {
tmp = Emitter;
2026-07-23 10:11:24 +00:00
for (const key10005 in Emitter.prototype) {
2026-07-20 16:05:17 +00:00
tmp2 = key10005;
2026-07-23 10:11:24 +00:00
tmp3 = Emitter;
arg0[key10005] = Emitter.prototype[key10005];
continue;
2026-07-20 16:05:17 +00:00
}
return global;
} else {
return;
}
}
once(arg0, arg1) {
2026-07-23 10:11:24 +00:00
closure_0 = global;
closure_1 = require;
2026-07-20 16:05:17 +00:00
on = function on() {
2026-07-29 08:29:29 +00:00
const self = this;
2026-07-23 10:11:24 +00:00
this.off(closure_0, on);
2026-07-29 08:29:29 +00:00
const apply = closure_1.apply;
if (typeof apply === "unknown") {
HermesBuiltin.applyArguments(self);
} else {
apply(self, arguments);
}
2026-07-20 16:05:17 +00:00
};
on.fn = require;
onResult = this.on(global, on);
return this;
}
emit(arg0) {
self = this;
2026-07-29 08:29:29 +00:00
tmp = this._callbacks || {};
self._callbacks = tmp;
2026-07-20 16:05:17 +00:00
array = new Array(arguments.length - 1);
arr = self._callbacks["$" + global];
num = 1;
if (1 < arguments.length) {
do {
array[num - 1] = arguments[num];
num = num + 1;
length = arguments.length;
} while (num < length);
}
if (arr) {
num2 = 0;
substr = require("module_0");
length2 = substr.length;
if (0 < length2) {
do {
obj = substr[num2];
applyResult = obj.apply(self, array);
num2 = num2 + 1;
} while (num2 < length2);
}
}
return self;
}
listeners(arg0) {
self = this;
2026-07-29 08:29:29 +00:00
tmp = this._callbacks || {};
self._callbacks = tmp;
tmp2 = self._callbacks["$" + global] || [];
return tmp2;
2026-07-20 16:05:17 +00:00
}
hasListeners(arg0) {
return this.listeners(global).length;
}
}
if (undefined !== module) {
module.exports = Emitter;
}
const fn = function(arg0, arg1) {
const self = this;
self._callbacks = this._callbacks || {};
let items = self._callbacks["$" + arg0];
const text = `$${arg0}`;
if (!items) {
items = [];
}
self._callbacks[text] = items;
items.push(arg1);
return self;
};
Emitter.prototype.addEventListener = fn;
Emitter.prototype.on = fn;
const fn2 = function(arg0, arg1) {
const self = this;
self._callbacks = this._callbacks || {};
if (0 == arguments.length) {
self._callbacks = {};
return self;
} else if (self._callbacks["$" + arg0]) {
if (1 == arguments.length) {
const _callbacks2 = self._callbacks;
const text = `$${arg0}`;
2026-07-23 10:11:24 +00:00
delete tmp2[tmp];
2026-07-20 16:05:17 +00:00
return self;
} else {
let num2 = 0;
if (0 < arr.length) {
while (arr[num2] !== arg1) {
2026-07-23 10:11:24 +00:00
if (tmp4.fn === arg1) {
2026-07-20 16:05:17 +00:00
break;
} else {
num2 = num2 + 1;
}
}
arr.splice(num2, 1);
}
if (0 === arr.length) {
const _callbacks = self._callbacks;
const text1 = `$${arg0}`;
2026-07-23 10:11:24 +00:00
delete tmp3[tmp2];
2026-07-20 16:05:17 +00:00
}
return self;
}
} else {
return self;
}
};
Emitter.prototype.removeEventListener = fn2;
Emitter.prototype.removeAllListeners = fn2;
Emitter.prototype.removeListener = fn2;
Emitter.prototype.off = fn2;