Something went wrong. Try again.
Central platform for European atproto.<cc> country community websites
Something went wrong. Try again.
123456789101112131415161718import type { FeedPost } from './types';
/** * Merge several authors' posts into one stream: dedupe by URI, newest first, * capped at `limit`. Pure — no I/O — so it's unit-tested directly. */export function mergeFeed(feeds: FeedPost[][], limit = 30): FeedPost[] { const byUri = new Map<string, FeedPost>(); for (const feed of feeds) { for (const post of feed) { if (!byUri.has(post.uri)) byUri.set(post.uri, post); } } return [...byUri.values()] .sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt)) .slice(0, limit);}