How to use the emojilib.hasOwnProperty function in emojilib

To help you get started, we’ve selected a few emojilib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github martellaj / commemoji / source / get_emoji.ts View on Github external
export function replaceWithEmojis (message: string): string {
  var words = message.split(' ');

  for (var i = 0; i < words.length; i++) {
    var query = words[i].toLowerCase().replace(/[^\w]/gi, '');

    // Search over all emojis, looking for a matching keyword.
    for (var key in emojis) {
      if (emojis.hasOwnProperty(key)) {
        if (key === query) {
          words[i] = words[i].toLowerCase().replace(key, ':' + query + ':');
          break;
        }
      }
    }
  }
  
  return words.join(' ');
}
github martellaj / commemoji / source / get_emoji.ts View on Github external
export function bySearch (query: string): string {
  var options = [];

  // Search over all emojis, looking for a matching keyword.
  for (var key in emojis) {
    if (emojis.hasOwnProperty(key)) {
      // If the keyword matches, add the emoji to an array of options.
      if (emojis[key].keywords && emojis[key].keywords.indexOf(query) > -1) {
        options.push(key);
      } else if (key.indexOf(query) > -1) {
        options.push(key);
      }
    }
  }

  // If any options have been found, return a random option.
  if (options.length > 0) {
    return ':' + options[Math.floor(Math.random() * options.length)] + ': ';
  } else {
    return null;
  }
}
github martellaj / commemoji / bin / source / get_emoji.js View on Github external
function replaceWithEmojis(message) {
    var words = message.split(' ');
    for (var i = 0; i < words.length; i++) {
        var query = words[i].toLowerCase().replace(/[^\w]/gi, '');
        for (var key in emojis) {
            if (emojis.hasOwnProperty(key)) {
                if (key === query) {
                    words[i] = words[i].toLowerCase().replace(key, ':' + query + ':');
                    break;
                }
            }
        }
    }
    return words.join(' ');
}
exports.replaceWithEmojis = replaceWithEmojis;
github martellaj / commemoji / bin / source / get_emoji.js View on Github external
function bySearch(query) {
    var options = [];
    for (var key in emojis) {
        if (emojis.hasOwnProperty(key)) {
            if (emojis[key].keywords && emojis[key].keywords.indexOf(query) > -1) {
                options.push(key);
            }
            else if (key.indexOf(query) > -1) {
                options.push(key);
            }
        }
    }
    if (options.length > 0) {
        return ':' + options[Math.floor(Math.random() * options.length)] + ': ';
    }
    else {
        return null;
    }
}
exports.bySearch = bySearch;