Skip to content

Commit

Permalink
fix(LimitedCollection): allow items to be stored if keepOverLimit is …
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
Digital39999 and kodiakhq[bot] authored May 22, 2023
1 parent 4784349 commit 9345d1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/discord.js/src/util/LimitedCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9345d1b

Please sign in to comment.