-
Notifications
You must be signed in to change notification settings - Fork 0
/
emojis.js
40 lines (34 loc) · 1.2 KB
/
emojis.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//@ts-check
const { readFile, writeFile } = require("fs/promises");
async function main() {
const list = JSON.parse(await readFile("./emojis.json", "utf-8"));
// here's an example of an item in the list
// {"codes":"1F600","char":"😀","name":"grinning face","category":"Smileys & Emotion (face-smiling)","group":"Smileys & Emotion","subgroup":"face-smiling"}
// please convert that to
// "grinning_face": "😀",
// ...
const emojis = list.reduce((acc, { name, char }) => {
// if its a skin tone, skip it
if (name.includes("skin tone")) return acc;
const newName = name
.replaceAll(" ", "_")
.replaceAll("-", "_")
.replaceAll("flag:_", "flag_")
.replaceAll(":", "_")
// utf8 quotes
.replaceAll("“", "")
.replaceAll("”", "")
// dots
.replaceAll(".", "")
.toLowerCase();
acc[newName] = char;
return acc;
}, {});
// log in yaml format
const yaml = Object.entries(emojis)
.map(([name, char]) => `${name}: "${char}"`)
.join("\n");
// write file
await writeFile("./emojis.yaml", yaml);
}
main();