Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (options) => {
delete require.cache[require.resolve('emoji-datasource')]
var emojiData = require('emoji-datasource')
var data = { compressed: true, emojis: {} }
emojiData.sort((a, b) => {
var aTest = a.sort_order || a.short_name,
bTest = b.sort_order || b.short_name
return aTest - bTest
})
emojiData.forEach((datum) => {
var keywords = []
var localImageSets = options.sets || sets
// Local images
datum.localImages = {}
localImageSets.forEach((set) => {
var key = `has_img_${set}`
if (datum[key]) {
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)
indexes = {};
categories.forEach ( ( category, i ) => {
data.categories[i] = {
name: category,
title: titles[i],
icon: icons[i],
emojis: []
};
indexes[category] = i;
});
emojiData.sort ( ( a, b ) => {
const aTest = a.sort_order || a.short_name,
bTest = b.sort_order || b.short_name;
return aTest - bTest;
});
emojiData.forEach ( datum => {
datum.name || (datum.name = datum.short_name.replace ( /\-/g, ' ' ) );
datum.name = inflection.titleize ( datum.name || '' );
if ( datum.category === 'Flags' ) {
const code = datum.short_name.split ( '-' )[1].toUpperCase ();
datum.name = `Flag of ${countries[code].name}`;
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 => {
module.exports = (options) => {
delete require.cache[require.resolve('emoji-datasource')]
var emojiData = require('emoji-datasource')
var data = {compressed: true, categories: [], emojis: {}, aliases: {}},
categoriesIndex = {}
categories.forEach((category, i) => {
let [name, id] = category
data.categories[i] = {id: id, name: name, emojis: []}
categoriesIndex[name] = i
})
emojiData.sort((a, b) => {
var aTest = a.sort_order || a.short_name,
bTest = b.sort_order || b.short_name
return aTest - bTest
})
emojiData.forEach((datum) => {
var category = datum.category,
keywords = [],
categoryIndex
if (!datum.category) {
throw new Error('“' + datum.short_name + '” doesn’t have a category')
}
if (options.sets) {
];
const sets = [
'apple',
'google',
'twitter',
'facebook',
'messenger',
];
catPairs.forEach((category, i) => {
const [name, id] = category;
categories[i] = { id: id, name: name, emojis: [] };
categoriesIndex[name] = i;
});
emojiData.sort((a: any, b: any) => {
const aTest = a.sort_order || a.short_name,
bTest = b.sort_order || b.short_name;
return aTest - bTest;
});
function missingSets(datum: any) {
const hidden: any[] = [];
sets.forEach(x => {
if (!datum[`has_img_${x}`]) {
hidden.push(x);
}
delete datum[`has_img_${x}`];
});
if (!hidden.length) {
return;