Update feed docs
This commit is contained in:
+20
-1
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user