-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemoji.js
47 lines (41 loc) · 1.45 KB
/
emoji.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
41
42
43
44
45
46
47
const path = require('path');
const fromPairs = require('lodash.frompairs');
const emoji = require('emoji-datasource-apple/emoji');
function defineEmoji(data, callback) {
const pairs = emoji.filter(e => e.has_img_apple).map((e) => {
const name = e.short_name;
const aliases = e.short_names.slice(1);
const ascii = (e.texts || []).map(x => x.replace(/</g, '<').replace(/>/g, '>'));
const character = e.unified
.split('-')
.map(code => String.fromCodePoint(parseInt(code, 16)))
.join('');
let category = e.category.toLowerCase();
if (category === 'skin tones') { category = 'modifier'; }
else if (category === 'foods') { category = 'food'; }
else if (category === 'places') { category = 'travel'; }
return [name, {
aliases,
ascii,
character,
categories: [category],
keywords: e.keywords,
image: e.image,
}];
});
const dictionary = fromPairs(pairs);
data.packs.push({
name: 'Apple',
id: 'apple',
path: __dirname,
attribution: 'From <a href="https://github.com/iamcal/emoji-data" target="_blank" rel="noopener">iamcal/emoji-data on Github</a>',
license: 'Copyright © Apple Inc. License terms unknown. Use at own risk.',
mode: 'images',
images: {
directory: path.join(path.dirname(require.resolve('emoji-datasource-apple')), 'img/apple/64'),
},
dictionary,
});
callback(null, data);
}
module.exports.defineEmoji = defineEmoji;