MCPcopy Create free account
hub / github.com/block/buzz / dedup

Function dedup

desktop/src/features/projects/hooks.ts:198–212  ·  view source on GitHub ↗
(events: RelayEvent[])

Source from the content-addressed store, hash-verified

196}
197
198function dedup(events: RelayEvent[]): RelayEvent[] {
199 const best = new Map<string, RelayEvent>();
200
201 for (const e of events) {
202 const d = getTag(e, "d") ?? "";
203 const key = `${e.pubkey}:${e.kind}:${d}`;
204 const prev = best.get(key);
205
206 if (!prev || e.created_at > prev.created_at) {
207 best.set(key, e);
208 }
209 }
210
211 return [...best.values()];
212}
213
214async function fetchProjects(): Promise<Project[]> {
215 const [events, deletionEvents] = await Promise.all([

Callers 2

fetchProjectsFunction · 0.70
fetchProjectFunction · 0.70

Calls 3

setMethod · 0.80
getTagFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected