From e875f304780e0d8108dbe1d7e7bdcf6ba9e9313f Mon Sep 17 00:00:00 2001 From: Christoffer Sandberg Date: Thu, 26 May 2022 19:28:46 +0200 Subject: [PATCH] Change argument order for add/remove match exist check Attempts to correct logic to intended behaviour. That is, check existing property `match` on `this._matchRules` instead of `this._matchRules` on `match`. --- lib/bus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bus.js b/lib/bus.js index 277491c..40de03d 100644 --- a/lib/bus.js +++ b/lib/bus.js @@ -483,7 +483,7 @@ class MessageBus extends EventEmitter { } _addMatch (match) { - if (Object.prototype.hasOwnProperty.call(match, this._matchRules)) { + if (Object.prototype.hasOwnProperty.call(this._matchRules, match)) { this._matchRules[match] += 1; return Promise.resolve(); } @@ -507,7 +507,7 @@ class MessageBus extends EventEmitter { return Promise.resolve(); } - if (Object.prototype.hasOwnProperty.call(match, this._matchRules)) { + if (Object.prototype.hasOwnProperty.call(this._matchRules, match)) { this._matchRules[match] -= 1; if (this._matchRules[match] > 0) { return Promise.resolve();