Update emojis search string

release
Etienne Lemay 2016-07-26 14:50:55 -04:00
parent b7023971ad
commit 9feee08e06
3 changed files with 22 additions and 11 deletions

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,6 @@
"rimraf": "2.5.2",
"svg-inline-loader": "0.4.1",
"svg-inline-react": "1.0.1",
"uniq": "1.0.1",
"webpack": "1.12.14"
},
"scripts": {

View File

@ -2,8 +2,7 @@ var fs = require('fs'),
emojiData = require('emoji-data'),
emojiLib = require('emojilib'),
inflection = require('inflection'),
mkdirp = require('mkdirp'),
uniq = require('uniq')
mkdirp = require('mkdirp')
var categories = ['People', 'Nature', 'Foods', 'Activity', 'Places', 'Objects', 'Symbols', 'Flags'],
data = { categories: [], emojis: {}, skins: {} },
@ -55,13 +54,26 @@ emojiData.forEach((datum) => {
}
datum.keywords = keywords
datum.search = uniq([]
.concat(datum.name.split(/[-|_|\s]+/))
.concat(datum.short_names)
.concat(datum.keywords)
.concat(datum.emoticons)
.map((s) => s.toLowerCase())
).join(',')
datum.search = []
var addToSearch = (strings, split) => {
(Array.isArray(strings) ? strings : [strings]).forEach((string) => {
(split ? string.split(/[-|_|\s]+/) : [string]).forEach((s) => {
s = s.toLowerCase()
if (datum.search.indexOf(s) == -1) {
datum.search.push(s)
}
})
})
}
addToSearch(datum.short_names, true)
addToSearch(datum.name, true)
addToSearch(datum.keywords, false)
addToSearch(datum.emoticons, false)
datum.search = datum.search.join(',')
if (datum.category == 'Skin Tones') {
data.skins[datum.short_name] = datum