fix ip counter to delete entry if 0
This commit is contained in:
parent
624a1811bc
commit
72567ffe6a
|
@ -26,7 +26,11 @@ export default class Counter<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(item: T): void {
|
delete(item: T): void {
|
||||||
const count = this.get(item);
|
const count = this.get(item) - 1;
|
||||||
this.map.set(item, count - 1);
|
if (count === 0) {
|
||||||
|
this.map.delete(item);
|
||||||
|
} else {
|
||||||
|
this.map.set(item, count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user