mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +00:00
allow disabling cache
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import { chooseRandom } from "./utils.ts";
|
||||
|
||||
export default class Collection<K, V> extends Map<K, V> {
|
||||
maxSize?: number
|
||||
|
||||
set(key: K, value: V) {
|
||||
// When this collection is maxSizeed make sure we can add first
|
||||
if (this.maxSize || this.maxSize === 0) {
|
||||
if (this.size >= this.maxSize) return this;
|
||||
}
|
||||
|
||||
return super.set(key, value);
|
||||
}
|
||||
|
||||
array() {
|
||||
return [...this.values()];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user