Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { writeFileSync } = require('fs');
const rawData = require('emoji-datasource');
function getEmoji(unified) {
const chars = unified.split('-');
const codePoints = chars.map(char => parseInt(char, 16));
return String.fromCodePoint(...codePoints);
}
rawData.sort((e1, e2) => e1.sort_order - e2.sort_order);
const newEmojiData = rawData.map(emojiItem => {
const newData = {
name: emojiItem.short_name,
key: emojiItem.short_name,
names: emojiItem.short_names,
emoji: getEmoji(emojiItem.unified),
category: emojiItem.category
};
if (emojiItem.skin_variations) {
newData.variants = {};
Object.keys(emojiItem.skin_variations).forEach(variation => {
newData.variants[variation] = {
name: emojiItem.short_name,
key: `${emojiItem.short_name}-${variation}`,
emoji: getEmoji(emojiItem.skin_variations[variation].unified)
};
const emojiData = require('emoji-datasource');
const categoryDataMap = require('./map').categoryDataMap;
const sortedEmojiData = emojiData
.map((emoji, index) => Object.assign(emoji, { index }))
.sort((emojiA, emojiB) => emojiA['sort_order'] - emojiB['sort_order'])
.reduce((obj, emoji) => {
const category = categoryDataMap[emoji.category];
const categoryArray = obj[category] || [];
return Object.assign(obj, {
[category]: categoryArray.concat(emoji)
});
}, {});
module.exports = sortedEmojiData;
const categoryKeys = {
'Smileys & People': 'smileys',
'Animals & Nature': 'animals',
'Food & Drink': 'food',
Activities: 'activities',
'Travel & Places': 'travel',
Objects: 'objects',
Symbols: 'symbols',
Flags: 'flags',
'Skin Tones': 'skinTones'
};
const categories = [];
rawData.sort((e1, e2) => e1.sort_order - e2.sort_order);
const newEmojiData = rawData.map(emojiItem => {
let categoryIndex = categories.indexOf(emojiItem.category);
if (categoryIndex < 0) {
categories.push(emojiItem.category);
categoryIndex = categories.length - 1;
}
const newData = {
n: emojiItem.short_names,
e: getEmoji(emojiItem.unified),
c: categoryIndex
};
if (emojiItem.skin_variations) {
newData.v = {};
Object.keys(emojiItem.skin_variations).forEach(variation => {
newData.v[variation] = {