How to use node-emoji

Comprehensive node-emoji code examples:

How to use node-emoji.forEach:

2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473


/*------------------ start get max descount ------------------*/
const getEmoji = async (req, res, next) => {
  var emoji = require("../../jsonFileForEmoji V2");
  var arrEmoji = [];
  emoji.forEach((ele) => {
    if (!arrEmoji.includes(ele) && ele.category == req.body.catigory) {
      arrEmoji.push(ele);
    }
  });

How to use node-emoji.find:

48
49
50
51
52
53
54
55
56
        data: regex.getInvalidEmojiResponse(emoji)
    };
}

// convert emoji into correct form
emoji = emoji_tool.find(emoji).emoji;

// hash the password before storing for security
const hash = bcrypt.hashSync(password, 10);

How to use node-emoji.random:

54
55
56
57
58
59
60
61
62
var emoji = require('node-emoji');


// Display an emoji picked randomly
controller.hears(['random'], 'direct_message,direct_mention', function (bot, message) {
    var random = emoji.random();
    var email = message.user; // Spark User that created the message orginally 
    bot.reply(message, "hey <@personEmail:" + email + ">, type `:" + random.key + ":` to get " + random.emoji);
});

How to use node-emoji.which:

11
12
13
14
15
16
17
18
19
20
}

for (i in input) {
  arg = input[i]

  if (typeof arg === 'string' && emoji.which(arg)) {
    arg += ' '
  }

  logs.push(arg)

How to use node-emoji.search:

68
69
70
71
72
73
74
75
76
77
if (!keyword) {
    bot.reply(message, "what are you exactly looking for ?");
    return;
}

var found = emoji.search(keyword);
switch (found.length) {
    case 0:
        bot.reply(message, "sorry, no match " + emoji.get("persevere"));
        return;

How to use node-emoji.unemojify:

107
108
109
110
111
112
113
114
115
116
        _sql = "UPDATE " + com.tbl.roomdtl + " SET STATE = '' WHERE ROOMID = '" + _roomid + "' AND STATE = '2' "
        await wsmysql.query(conn, _sql, null)
}
let bodyForInsert
if (obj.type == 'talk' && ws.util.chkEmoji(obj.body)) {
        bodyForInsert = emoji.unemojify(obj.body)
        if (ws.util.utf8StrByteLength(bodyForInsert) > com.cons.max_msg_len) throw new Error('Max size of talk is ' + com.cons.max_msg_len + '. Now is ' + ws.util.utf8StrByteLength(bodyForInsert) + '.') 
} else {
        bodyForInsert = obj.body
}

How to use node-emoji.strip:

28
29
30
31
32
33
34
35
36
37
38
const isBranchValid = name =>
  /^[a-zA-Z0-9-]*$/.test(name);


const checkTitle = async (context, rules, parser, report) => {
  const pull = context.payload.pull_request;
  const clean = strip(pull.title);
  const emoji = replace(Array.from(pull.title)[0], e => `${e.key}`);
  const linter = await lint(clean, rules, parser);
  const errors = [];
  const warnings = [];

How to use node-emoji.indexOf:

179
180
181
182
183
184
185
186
187
188
return str.split(emojiNameRegex) // parse emoji via regex
          .map(function parseEmoji(s, i) {
            // every second element is an emoji, e.g. "test :fast_forward:" -> [ "test ", "fast_forward" ]
            if (i % 2 === 0) return s;
            var emoji = Emoji._get(s);
            var isMissing = emoji.indexOf(':') > -1;

            if (isMissing && typeof on_missing === 'function') {
              return on_missing(s);
            }

How to use node-emoji.replace:

290
291
292
293
294
295
296
297
298
const codeFriendly = text.text.content
  .replace(/</g, "&lt;")
  .replace(/>/g, "&gt;");

/** @type {Set<string>} */ const emojiToLoad = new Set([]);
let content = emoji.replace(codeFriendly, ({ emoji }) => {
  emojiToLoad.add(emoji);
  return emoji;
});

How to use node-emoji.emojify:

29
30
31
32
33
34
35
36
37
38
  _write(msg){
    this.log(this._format(msg))
  }

  _format(msg){
    return emoji.emojify(msg)
  }
}

/**

How to use node-emoji.get:

150
151
152
153
154
155
156
157
158
159
 * @param entityType Entity to listen for events
 * @param fromSeq the starting point to begin listening for events (0 is from the beginning of time)
 */
async function listenForNileEvents(entityType: string, fromSeq: number) {
  console.log(
    emoji.get('ear')+` Listening for events for ${entityType} entities from sequence #${fromSeq}`
  );
  await new Promise(() => {
    // TODO: buffer events keyed by entity id and only execute the latest state
    nile.events.on({ type: entityType, seq: fromSeq }, async (e) => {