From e273dbc4d5bc3f6521c480590fe59785a5d7a2db Mon Sep 17 00:00:00 2001 From: Laxuzer <64734729+Laxuzer@users.noreply.github.com> Date: Sun, 14 Nov 2021 22:22:30 +0300 Subject: [PATCH] Delete EventEmitter.js --- src/base/EventEmitter.js | 58 ---------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 src/base/EventEmitter.js diff --git a/src/base/EventEmitter.js b/src/base/EventEmitter.js deleted file mode 100644 index f69ac48..0000000 --- a/src/base/EventEmitter.js +++ /dev/null @@ -1,58 +0,0 @@ -class EventEmitter { - constructor() { - this.events = {}; - this.eventsArray = []; - } - /** - * @param { String } a - * @param { Function } callback - * @returns events - */ - on(a, callback) { - this.events[a] = this.events[a] || []; - if (!this.eventsArray.includes(a)) this.eventsArray.push(a); - this.events[a].push({ - id: new Date().getTime(), - code: callback, - type: "on" - }); - return this - } - - /** - * @param { String } a - * @param {...any} arg - */ - emit(a, ...arg) { - if (this.events[a]) { - this.events[a].forEach(b => { - b["code"](...arg); - switch (b["type"]) { - case "once": - this.events[a] = elementdelete(this.events[a], b); - break; - - } - }); - } - } - - once(a, callback) { - this.events[a] = this.events[a] || []; - this.events[a].push({ - id: new Date().getTime(), - code: callback, - type: "once" - }); - return this - } -} - -function elementdelete(a, b) { - if (a.includes(b)) { - return a.splice(a.indexOf(b), 1) - }; - return a -} - -module.exports = EventEmitter; \ No newline at end of file