CharlieBoyer HF Staff commited on
Commit
6f6f2f9
·
verified ·
1 Parent(s): 37a4be9

Update src/server.ts

Browse files
Files changed (1) hide show
  1. src/server.ts +5 -3
src/server.ts CHANGED
@@ -31,10 +31,12 @@ class IdempotencyCache {
31
  constructor(maxSize = 2000) { this.maxSize = maxSize; }
32
  has(uuid: string) { return this.map.has(uuid); }
33
  add(uuid: string) {
34
- this.map.set(uuid, true);
35
- if (this.map.size > this.maxSize) {
36
- const firstKey = this.map.keys().next().value;
 
37
  this.map.delete(firstKey);
 
38
  }
39
  }
40
  }
 
31
  constructor(maxSize = 2000) { this.maxSize = maxSize; }
32
  has(uuid: string) { return this.map.has(uuid); }
33
  add(uuid: string) {
34
+ this.map.set(uuid, true);
35
+ if (this.map.size > this.maxSize) {
36
+ const firstKey = this.map.keys().next().value as string | undefined;
37
+ if (firstKey !== undefined) {
38
  this.map.delete(firstKey);
39
+ }
40
  }
41
  }
42
  }