Add emoji parsing and utils
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@welshman/util",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"author": "hodlbod",
|
||||
"license": "MIT",
|
||||
"description": "A collection of nostr-related utilities.",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {uniqBy, mapVals, nth, nthEq, ensurePlural} from "@welshman/lib"
|
||||
import {uniqBy, first, spec, mapVals, nth, nthEq, ensurePlural} from "@welshman/lib"
|
||||
import {isRelayUrl} from "./Relay.js"
|
||||
import {Address} from "./Address.js"
|
||||
|
||||
@@ -106,6 +106,15 @@ export const getReplyTags = (tags: string[][]) => {
|
||||
export const getReplyTagValues = (tags: string[][]) =>
|
||||
mapVals(tags => tags.map(nth(1)), getReplyTags(tags))
|
||||
|
||||
export const getEmojiTags = (name: string, tags: string[][]) => tags.filter(spec(["emoji", name]))
|
||||
|
||||
export const getEmojiTag = (name: string, tags: string[][]) => first(getEmojiTags(name, tags))
|
||||
|
||||
export const getEmojiTagUrls = (name: string, tags: string[][]) =>
|
||||
getEmojiTags(name, tags).map(nth(2))
|
||||
|
||||
export const getEmojiTagUrl = (name: string, tags: string[][]) => first(getEmojiTagUrls(name, tags))
|
||||
|
||||
export const uniqTags = (tags: string[][]) => uniqBy(t => t.slice(0, 2).join(":"), tags)
|
||||
|
||||
export const tagsFromIMeta = (imeta: string[]) => imeta.map((m: string) => m.split(" "))
|
||||
|
||||
Reference in New Issue
Block a user