Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fs = require('fs');
const _ = require('lodash');
const csvWriter = require('csv-write-stream');
const csvParse = require('csv-parse/lib/sync');
const emojibaseData = require('emojibase-data/en/data.json');
const emojibaseGroups = require('emojibase-data/meta/groups.json');
const groups = emojibaseGroups.groups;
const subgroups = emojibaseGroups.subgroups;
// -- helper functions --
const loadCsv = (filePath) => {
const content = fs.readFileSync(filePath, 'utf8');
return csvParse(content, {columns: true});
}
const arrayToEmojiDict = (array) => {
return array.reduce((o, a) => Object.assign(o, { [a.emoji]: a }), {});
}
const writeCsv = (data, filePath) => {
const csvOut = csvWriter();
csvOut.pipe(fs.createWriteStream(filePath));
for (d of data) csvOut.write(d);
csvOut.end();
})
}
}
if (emojiGroupFound !== undefined) {
emojiGroup.emojiList.push(emojiObj);
} else {
emojiGroup.emojiList.push(emojiObj);
emojiArray.push(emojiGroup);
}
}
const emojiArrayString = JSON.stringify(emojiArray);
console.log('emoji-data/emoji-all-groups.json');
fs.writeFileSync(`../emoji-data/emoji-all-groups.json`, emojiArrayString, 'utf-8');
const groupMeta = groupMetaData.groups;
for (let i = 0; i < emojiArray.length; i++) {
let emojiGroupName = '';
for (let group in groupMeta) {
if(group == emojiArray[i].group) {
emojiGroupName = groupMeta[group];
break;
}
}
const emojiGroupString = JSON.stringify(emojiArray[i]);
console.log(`emoji-data/emoji-group-${emojiGroupName}.json`);
fs.writeFileSync(`../emoji-data/emoji-group-${emojiGroupName}.json`, emojiGroupString, 'utf-8');
}
emojiObj.skins.push({
unicode: emojiPackLang[i].skins[j].unicode,
tags: emojiPackLang[i].skins[j].tags
})
}
}
if (emojiGroupFound !== undefined) {
emojiGroup.emojiList.push(emojiObj);
} else {
emojiGroup.emojiList.push(emojiObj);
emojiArray.push(emojiGroup);
}
}
const groupMeta = groupMetaData.groups;
for (let i = 0; i < emojiArray.length; i++) {
if (i === 2) { continue; }
else {
let emojiGroupName = '';
for (let group in groupMeta) {
if(group == emojiArray[i].group) {
emojiGroupName = groupMeta[group];
break;
}
}
const emojiGroupString = JSON.stringify(emojiArray[i]);
console.log(`emoji-data/${lang}/emoji-group-${emojiGroupName}.json`);
fs.writeFileSync(`./src/emoji-data/${lang}/emoji-group-${emojiGroupName}.json`, emojiGroupString, 'utf-8');
}
}