()
| 3 | start() |
| 4 | |
| 5 | async function start() { |
| 6 | const path = `dist/emoji-en-US.json` |
| 7 | const allEmojiData = require(`../${path}`) |
| 8 | const missing = await generateAugmentations(allEmojiData) |
| 9 | let addedCounts = {} |
| 10 | |
| 11 | for (const emoji in allEmojiData) { |
| 12 | const existing = allEmojiData[emoji] |
| 13 | const existingLikeWords = existing.join('_').split(/[ _]/) |
| 14 | const existingLowerCase = existing.map(keyword => keyword.toLowerCase()) |
| 15 | const missingKeywords = missing[emoji]?.filter( |
| 16 | keyword => |
| 17 | /[A-z]/.test(keyword) && |
| 18 | !keyword.includes('_') && |
| 19 | !existingLikeWords.includes(keyword) && |
| 20 | !existingLowerCase.includes(keyword) |
| 21 | ) |
| 22 | |
| 23 | if (missingKeywords?.length) { |
| 24 | allEmojiData[emoji] = [...existing, ...missingKeywords] |
| 25 | addedCounts[emoji] = missingKeywords.length |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | fs.writeFileSync(`./${path}`, JSON.stringify(allEmojiData, null, 2)) |
| 30 | const addedTo = Object.keys(addedCounts).length |
| 31 | const addedTotal = Object.values(addedCounts).reduce((a, b) => a + b, 0) |
| 32 | console.log('Augmented', addedTo, 'emoji with a total of', addedTotal, 'keyword(s)') |
| 33 | } |
| 34 | |
| 35 | async function generateAugmentations(existingData) { |
| 36 | const emojipedia = await import('emojipedia/data') |
no test coverage detected