podcast manager
1export class StrictMap<K, V> extends Map<K, V> {
2 require(key: K): V {
3 if (!this.has(key)) throw Error(`key is required but not in the map`);
4
5 return this.get(key) as V;
6 }
7
8 ensure(key: K, maker: () => V): V {
9 if (!this.has(key)) {
10 this.set(key, maker());
11 }
12
13 return this.get(key) as V;
14 }
15
16 update(key: K, update: (v?: V) => V) {
17 const current = this.get(key);
18 this.set(key, update(current));
19 }
20}