emit and receive events!
目前為
此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/426233/929468/Simple%20EventEmitter.js
const EventEmitter = class {
constructor() {
this.a = {};
}
on(t, s) {
!this.a[t] && (this.a[t] = []), this.a[t].push(s);
}
emit(t, s) {
let a = this.a[t];
a && a.forEach(t => t(s));
}
};