Simple EventEmitter

emit and receive events!

As of 21.06.2021. See ბოლო ვერსია.

ეს სკრიპტი არ უნდა იყოს პირდაპირ დაინსტალირებული. ეს ბიბლიოთეკაა, სხვა სკრიპტებისთვის უნდა ჩართეთ მეტა-დირექტივაში // @require https://update.greatest.deepsurf.us/scripts/426233/942855/Simple%20EventEmitter.js.

const EventEmitter = class {
    constructor() {
        this.a = {};
    }
    on(t, s) {
        !this.a[t] && (this.a[t] = []), this.a[t].push(s);
    }
    once(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));
    }
};