From 2de83100a02b8374686ee6a318d882e0e96e820a Mon Sep 17 00:00:00 2001 From: Etienne Lemay Date: Fri, 10 Mar 2017 12:11:05 -0500 Subject: [PATCH] Delete empty arrays from data file --- scripts/build-data.js | 8 ++++++++ src/utils/emoji-index.js | 2 +- src/utils/index.js | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/build-data.js b/scripts/build-data.js index 52593fd..420b7c6 100644 --- a/scripts/build-data.js +++ b/scripts/build-data.js @@ -93,6 +93,14 @@ emojiData.forEach((datum) => { delete datum.short_name delete datum.category 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']]; diff --git a/src/utils/emoji-index.js b/src/utils/emoji-index.js index 4bb245b..7a97f47 100644 --- a/src/utils/emoji-index.js +++ b/src/utils/emoji-index.js @@ -11,7 +11,7 @@ for (let emoji in data.emojis) { { short_names, emoticons } = emojiData, id = short_names[0] - for (let emoticon of emoticons) { + for (let emoticon of (emoticons || [])) { if (!emoticonsList[emoticon]) { emoticonsList[emoticon] = id } diff --git a/src/utils/index.js b/src/utils/index.js index e00c47d..5078e68 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -68,6 +68,9 @@ function getData(emoji, skin, set) { } } + emojiData.emoticons || (emojiData.emoticons = []) + emojiData.variations || (emojiData.variations = []) + if (emojiData.skin_variations && skin > 1 && set) { emojiData = JSON.parse(JSON.stringify(emojiData))