fix(LimitedCollection): allow items to be stored if keepOverLimit is true when maxSize is 0 (#9534)

Update LimitedCollection.js

Keep value if it matches the limit.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Digital
2023-05-22 10:11:47 +02:00
committed by GitHub
parent 47843493a5
commit 9345d1b1ac

View File

@@ -47,7 +47,7 @@ class LimitedCollection extends Collection {
}
set(key, value) {
if (this.maxSize === 0) return this;
if (this.maxSize === 0 && !this.keepOverLimit?.(value, key, this)) return this;
if (this.size >= this.maxSize && !this.has(key)) {
for (const [k, v] of this.entries()) {
const keep = this.keepOverLimit?.(v, k, this) ?? false;