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
Vitor Pamplona 1y ago

I loop through tags so much that my main priority is to minimize alloc as much as possible. The filter -> map creates two lists and would already create Garbage Collection problems when scrolling.

Reply to this note

Please Login to reply.

Discussion

No replies yet.