-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEmojiConverter.js
51 lines (44 loc) · 1005 Bytes
/
EmojiConverter.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
48
49
50
51
var EmojiData = require('emoji-data-2016'),
countryLookup = require('country-data').lookup
/*var flagsMap =
{
US: '1F1FA-1F1F8'
}*/
function getCountryCode(countryName)
{
var country = countryLookup.countries({name: countryName})[0]
// console.log(country)
return country.alpha2
}
function getEmoji(countryName)
{
var emoji = null,
countryCode = getCountryCode(countryName)
if (countryCode)
{
// console.log('Finding an emoji for ' + countryCode)
emoji = EmojiData.from_short_name(countryCode)
if (!emoji) emoji = EmojiData.from_short_name('flag-' + countryCode)
// EmojiData.from_unified(flagsMap[countryCode])
// if (emoji) console.log(emoji.render())
}
return emoji
}
module.exports =
{
getEmoji: getEmoji
}
/*
getEmoji('United States')
getEmoji('Kyrgyzstan')
getEmoji('Thailand')
getEmoji('Italy')
getEmoji('Poland')
getEmoji('France')
getEmoji('United Kingdom')
getEmoji('Canada')
getEmoji('Germany')
getEmoji('Japan')
getEmoji('Ireland')
// getEmoji('')
*/