From 5c64cc69088a3abd32412bdc0f5a984700e85d46 Mon Sep 17 00:00:00 2001 From: Peder Johnsen Date: Sat, 23 Mar 2019 21:14:52 +0000 Subject: [PATCH] Use for loop and refactor lookup code --- src/utils/index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 2e1dcfa..1b66fad 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -157,19 +157,23 @@ function getEmojiDataFromNative(nativeString, set, data) { } }) - const emojiData = Object.values(data.emojis).find((emoji) => { - emoji = JSON.parse(_JSON.stringify(emoji)) + let emojiData; + + for (let id in data.emojis) { + let emoji = data.emojis[id] + + let emojiUnified = emoji.unified if (emoji.variations && emoji.variations.length) { - emoji.unified = emoji.variations.shift() + emojiUnified = emoji.variations.shift() } if (skin && emoji.skin_variations && emoji.skin_variations[skinCode]) { - emoji.unified = emoji.skin_variations[skinCode].unified + emojiUnified = emoji.skin_variations[skinCode].unified } - return unifiedToNative(emoji.unified) === baseNativeString - }) + if (unifiedToNative(emojiUnified) === baseNativeString) emojiData = emoji + } if (!emojiData) { return null