muan/emojilib

Remove the `keys` array

IonicaBizau opened this issue ยท 5 comments

Do we we really need the keys array? It can be easily obtained using Object.keys(emoji). ๐Ÿ’ญ

Currently I causes some trouble because I want to check if a word is emoji, so emoji[myWord] will fail for myWord === "keys" (it's not an emoji object but an array).

Looks like it's anyway causing some problems on the Emoji Searcher page:

image

I'm almost sure there is no :keys: aliased with :-1: but it's just an issue because of the keys object.

So, is the keys array really needed? I would vote to be removed. ๐ŸŽˆ

Obviously, for now I will just delete emoji.keys โ‡๏ธ But would be handy not to be there at all.

muan commented

I added keys to provide an ordered list of emojis (in order of category & it's position within a category). Object.keys returns an unordered array, instead of the order it appears in the JSON file. ๐Ÿ˜” I know it's weird and unideal but I don't see a way around it.

Maybe namespace it somehow, then? A suggestion would be to take out the keys array from emojis.json and put it into keys.json and in the js side to do:

module.exports = {
    emojis: require("./emojis")
  , keys: require("./keys")
};

Would make the things smoother. ๐Ÿ˜

muan commented

Yup that totally make sense.

@muan Can I create pull request with this change?