Fix compilation error, add mergeRepositoryUpdates

This commit is contained in:
Jon Staab
2025-10-27 10:39:36 -07:00
parent bf6c240c73
commit e2bdb88cc2
13 changed files with 30 additions and 12 deletions
+18
View File
@@ -20,6 +20,24 @@ export type RepositoryUpdate = {
removed: Set<string>
}
export const mergeRepositoryUpdates = (updates: RepositoryUpdate[]): RepositoryUpdate => {
const added: TrustedEvent[] = []
const removed = new Set<string>()
for (const update of updates) {
for (const event of update.added) {
added.push(event)
removed.delete(event.id)
}
for (const id of update.removed) {
removed.add(id)
}
}
return {added, removed}
}
export class Repository extends Emitter {
eventsById = new Map<string, TrustedEvent>()
eventsByAddress = new Map<string, TrustedEvent>()