All files / src/database/seeds seed-id-registry.ts

0% Statements 0/10
0% Branches 0/6
0% Functions 0/4
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                             
export class SeedIdRegistry {
  private static readonly store = new Map<string, string[]>();
 
  static register(key: string, ids: string[]): void {
    const existing = this.store.get(key) || [];
    this.store.set(key, Array.from(new Set([...existing, ...ids])));
  }
 
  static get(key: string): string[] {
    return this.store.get(key) || [];
  }
 
  static getRandom(key: string): string | undefined {
    const list = this.get(key);
    if (!list.length) return undefined;
    return list[Math.floor(Math.random() * list.length)];
  }
 
  static clear(): void {
    this.store.clear();
  }
}