From 72567ffe6a1e5a6bbeda508096374b546d42284e Mon Sep 17 00:00:00 2001 From: HF Date: Fri, 19 Mar 2021 00:21:15 +0100 Subject: [PATCH] fix ip counter to delete entry if 0 --- src/utils/Counter.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/Counter.js b/src/utils/Counter.js index 578eff1..735a733 100644 --- a/src/utils/Counter.js +++ b/src/utils/Counter.js @@ -26,7 +26,11 @@ export default class Counter { } delete(item: T): void { - const count = this.get(item); - this.map.set(item, count - 1); + const count = this.get(item) - 1; + if (count === 0) { + this.map.delete(item); + } else { + this.map.set(item, count); + } } }