Update feed docs

This commit is contained in:
Jon Staab
2025-06-10 14:15:45 -07:00
parent 26739f9271
commit 5b73c507b7
4 changed files with 227 additions and 510 deletions
+20 -1
View File
@@ -45,7 +45,8 @@ const feed: Feed = makeDVMFeed({ kind: 5300 })
if (isDVMFeed(feed)) {
// feed is now typed as DVMFeed
const [kind] = feed.slice(1)
const [item] = getFeedArgs(feed)
const kind = item.kind
}
if (hasSubFeeds(feed)) {
@@ -122,6 +123,24 @@ walkFeed(feed, (node) => {
})
```
## Feed Simplification
Flatten nested feeds of the same type:
```typescript
// Simplifies nested feeds of the same type
export declare const simplifyFeed: (feed: Feed) => Feed
// Example: flatten nested union feeds
const nested = makeUnionFeed(
makeAuthorFeed("pubkey1"),
makeUnionFeed(makeKindFeed(1), makeKindFeed(6))
)
const simplified = simplifyFeed(nested)
// Result: [FeedType.Union, [FeedType.Author, "pubkey1"], [FeedType.Kind, 1], [FeedType.Kind, 6]]
```
## Type Extraction
Get typed arguments from feeds: