replaced fusejs in Emojiboard

This commit is contained in:
unknown 2021-08-25 15:00:40 +05:30
parent c06a92e0ae
commit 633d59c13b
3 changed files with 30 additions and 39 deletions

View file

@ -1,6 +1,5 @@
import emojisData from 'emojibase-data/en/compact.json';
import shortcodes from 'emojibase-data/en/shortcodes/joypixels.json';
import Fuse from 'fuse.js';
const emojiGroups = [{
name: 'Smileys & people',
@ -62,18 +61,7 @@ emojisData.forEach((emoji) => {
addToGroup(em);
emojis.push(em);
});
function searchEmoji(term) {
const options = {
includeScore: true,
keys: ['shortcodes', 'annotation', 'tags'],
threshold: '0.3',
};
const fuse = new Fuse(emojis, options);
let result = fuse.search(term);
if (result.length > 20) result = result.slice(0, 20);
return result;
}
export {
emojis, emojiGroups, searchEmoji,
emojis, emojiGroups,
};