1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-24 11:38:11 +09:00
hotomoe/src/misc/extract-emojis.ts
Aya Morisawa e9f8897fe2
Refactor MFM
Co-authored-by: syuilo syuilotan@yahoo.co.jp
2018-12-20 19:42:10 +09:00

10 lines
423 B
TypeScript

import { EmojiNode, MfmForest } from '../mfm/parser';
import { preorderF } from '../prelude/tree';
import { unique } from '../prelude/array';
export default function(mfmForest: MfmForest): string[] {
const emojiNodes = preorderF(mfmForest).filter(x => x.type === 'emoji') as EmojiNode[];
const emojis = emojiNodes.filter(x => x.props.name && x.props.name.length <= 100).map(x => x.props.name);
return unique(emojis);
}