thelounge/client/js/helpers/ircmessageparser/findEmoji.ts
2022-05-21 11:56:03 -07:00

26 lines
427 B
TypeScript

import emojiRegExp from "emoji-regex";
import {Part} from "./merge";
const regExp = emojiRegExp();
function findEmoji(text: string) {
const result: EmojiPart[] = [];
let match;
while ((match = regExp.exec(text))) {
result.push({
start: match.index,
end: match.index + match[0].length,
emoji: match[0],
});
}
return result;
}
export type EmojiPart = Part & {
emoji: string;
};
export default findEmoji;