Replying to Avatar hodlbod

Devs, what's your favorite abstraction over tags you've seen? Here's what I currently have:

Array.from(Tags.from(event).type("p").values())

Tags implements Iterable, so you have to call Array.from. I used to have an `all` method that did the same, which actually seems less error prone.

I know some of you will probably say you don't need one, just do:

event.tags.filter(t => t[0] === "p").map(t => t[1])

This is ok, I prefer the former as a matter of taste, but the abstraction is nice when supporting things like positional/marked tags, which can get pretty complex.

#devstr

Avatar
ben 1y ago

I like the helper methods the CEO himself put in the Go sdk. the tests show the functionality:

https://github.com/nbd-wtf/go-nostr/blob/master/tag_test.go

Reply to this note

Please Login to reply.

Discussion

No replies yet.