perf(frontend): emojilistのサイズ削減
This commit is contained in:
parent
f551b6d15e
commit
dc031b1d07
4 changed files with 1792 additions and 1817 deletions
|
@ -2,7 +2,6 @@ export const unicodeEmojiCategories = ['face', 'people', 'animals_and_nature', '
|
|||
|
||||
export type UnicodeEmojiDef = {
|
||||
name: string;
|
||||
keywords: string[];
|
||||
char: string;
|
||||
category: typeof unicodeEmojiCategories[number];
|
||||
}
|
||||
|
@ -10,11 +9,16 @@ export type UnicodeEmojiDef = {
|
|||
// initial converted from https://github.com/muan/emojilib/commit/242fe68be86ed6536843b83f7e32f376468b38fb
|
||||
import _emojilist from '../emojilist.json';
|
||||
|
||||
export const emojilist = _emojilist as UnicodeEmojiDef[];
|
||||
export const emojilist: UnicodeEmojiDef[] = _emojilist.map(x => ({
|
||||
name: x[1] as string,
|
||||
char: x[0] as string,
|
||||
category: unicodeEmojiCategories[x[2]],
|
||||
}));
|
||||
|
||||
const _indexByChar = new Map<string, number>();
|
||||
const _charGroupByCategory = new Map<string, string[]>();
|
||||
emojilist.forEach((emo, i) => {
|
||||
for (let i = 0; i < emojilist.length; i++) {
|
||||
const emo = emojilist[i];
|
||||
_indexByChar.set(emo.char, i);
|
||||
|
||||
if (_charGroupByCategory.has(emo.category)) {
|
||||
|
@ -22,7 +26,7 @@ emojilist.forEach((emo, i) => {
|
|||
} else {
|
||||
_charGroupByCategory.set(emo.category, [emo.char]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const emojiCharByCategory = _charGroupByCategory;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue