jormungandr-bite/packages/backend/src/misc/extract-custom-emojis-from-mfm.ts
ThatOneCalculator 2aab2de38d refactor: 🎨 rome
2023-01-12 20:40:33 -08:00

10 lines
335 B
TypeScript

import * as mfm from "mfm-js";
import { unique } from "@/prelude/array.js";
export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
const emojiNodes = mfm.extract(nodes, (node) => {
return node.type === "emojiCode" && node.props.name.length <= 100;
});
return unique(emojiNodes.map((x) => x.props.name));
}