muan / emojilib

Emoji keyword library.
https://unpkg.com/emojilib@latest
MIT License
1.66k stars 295 forks source link

Remove the `keys` array #34

Closed IonicaBizau closed 8 years ago

IonicaBizau commented 8 years ago

Do we we really need the keys array? It can be easily obtained using Object.keys(emoji). :thought_balloon:

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. :balloon:

IonicaBizau commented 8 years ago

Obviously, for now I will just delete emoji.keys :sparkle: But would be handy not to be there at all.

muan commented 8 years ago

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. :pensive: I know it's weird and unideal but I don't see a way around it.

IonicaBizau commented 8 years ago

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. :grin:

muan commented 8 years ago

Yup that totally make sense.

IonicaBizau commented 8 years ago

@muan Can I create pull request with this change?