allow disabling cache

This commit is contained in:
Skillz
2020-05-30 17:39:13 -04:00
parent f51fffe4e3
commit e5c5a04726
+11
View File
@@ -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()];
}