is-emoji

Simple module to testing emoji characters


Keywords
emoji, text, string
License
MIT
Install
npm install is-emoji@0.1.1

Documentation

is-emoji Build Status

Simple enough:

var isEmoji = require('is-emoji');

isEmoji('🌻'); // true
isEmoji('🌻'); // true

// for string iteration, since emoji char will be broken up over two indexes.
var str = 'abc🚲def';

for (var i = 0; i < str.length; i++) {
  var s = str[i];
  // will be true for i == 3, which will tell you
  if (isEmoji.isFirstCharCode(s.charCodeAt(0))) {
    // the character is 4 bytes, so concatenate them
    s += str[i+1];
  }

  console.log(s);
}