export class AliasMapper { private aliasMap = new Map() generateAlias(key: unknown): string { const alias = Math.random().toString(36).substring(2, 15) this.aliasMap.set(alias, key) return alias } getAlias(alias: string): unknown { return this.aliasMap.get(alias) } clear() { this.aliasMap.clear() } async process>( data: Record, processor: (key: unknown, value: T) => void | Promise, ): Promise { for (const [alias, value] of Object.entries(data)) { const originalKey = this.getAlias(alias) if (originalKey !== undefined) { await processor(originalKey, value) } } } }