Delete empty arrays from data file

release
Etienne Lemay 2017-03-10 12:11:05 -05:00
parent dbf22073c8
commit 2de83100a0
3 changed files with 12 additions and 1 deletions

View File

@ -93,6 +93,14 @@ emojiData.forEach((datum) => {
delete datum.short_name delete datum.short_name
delete datum.category delete datum.category
delete datum.sort_order delete datum.sort_order
for (let key in datum) {
let value = datum[key]
if (Array.isArray(value) && !value.length) {
delete datum[key]
}
}
}) })
var flags = data.categories[categoriesIndex['Flags']]; var flags = data.categories[categoriesIndex['Flags']];

View File

@ -11,7 +11,7 @@ for (let emoji in data.emojis) {
{ short_names, emoticons } = emojiData, { short_names, emoticons } = emojiData,
id = short_names[0] id = short_names[0]
for (let emoticon of emoticons) { for (let emoticon of (emoticons || [])) {
if (!emoticonsList[emoticon]) { if (!emoticonsList[emoticon]) {
emoticonsList[emoticon] = id emoticonsList[emoticon] = id
} }

View File

@ -68,6 +68,9 @@ function getData(emoji, skin, set) {
} }
} }
emojiData.emoticons || (emojiData.emoticons = [])
emojiData.variations || (emojiData.variations = [])
if (emojiData.skin_variations && skin > 1 && set) { if (emojiData.skin_variations && skin > 1 && set) {
emojiData = JSON.parse(JSON.stringify(emojiData)) emojiData = JSON.parse(JSON.stringify(emojiData))