is-emoji
v0.1.1
Published
Simple module to testing emoji characters
Downloads
887
Readme
is-emoji
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);
}