Simple EventEmitter

emit and receive events!

As of 2021-05-09. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.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));
    }
};