npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

emoji-reader

v2.0.5

Published

A simple tool to recognize Emoji in string

Downloads

15

Readme

emoji-reader

A simple tool to recognize Emoji in string.

npm version

Preview: https://emoji-reader.netlify.app

Feature

  • Support Unicode 12 specification, [click here to view] 1

  • The 'Emoji' judgment based on EBNF state machine, which is easier to maintain than regular expressions

  • Accurately judge the length of the string containing 'Emoji'

  • Exact cut string safely without breaking 'Emoji'

String Length

| Emoji | String.length | EmojiReader.getTextLength | | :----:| :----: | :----: | | ♀ | 1 | 1 | | 🙂 | 2 | 1 | |👱‍♂|5|1| |🏳️‍🌈|6|1| | 👨‍👩‍👦‍👦 | 11| 1 |

Within a string, an 'Emoji' consists of either one or more Unicode code points. A code point may consist of multiple characters (depending on whether the code point is greater than 0x010000). Therefore, an 'Emoji' may consist of several characters.

Many businesses need to judge the number of words, such as the user's nickname can not be too long, the speech content has the word limit and so on. If you do not make special treatment for 'Emoji', it will not meet the user's expectation.

Use EmojiReader.getTextLength to obtain the length of the visual symbol of the text. The length of an 'Emoji' is 1.

//Java
String strWithEmoji = "我是一个😃";
int error = strWithEmoji.length(); //6
int correct = EmojiReader.getTextLength(strWithEmoji); //5
//JavaScript
const strWithEmoji = '我是一个😃';
const error = strWithEmoji.length; //6
const correct = require('emoji-reader').getTextLength(strWithEmoji); //5

SubString

When the display text is too long, we usually omit the text at the end and add an ellipsis.

However, if the string contains 'Emoji', it is likely to cut the 'Emoji' into segments and turn it into garbled code.

For example, the following string:

"I am 🙂😐😎💏"

After invoke String.subString(0, 8) will become:

"I am 🙂?"

Because the display of 'Emoji' is completed by the combination of multiple Unicode code points. After subString, the remaining Unicode code points will show mess symbol that cannot be displayed normally.

Using EmojiReader.subSequence, the String can be cropped correctly according to the visual expectation.

//JavaScript
import EmojiReader from 'emoji-reader';
//Java
import com.yy.mobile.emoji.EmojiReader;

EmojiReader.subSequence("I am 🙂😐😎💏", 0, 8) == "I am 🙂😐😎"

Install (for Js)

npm install --save emoji-reader

Install (for Java/Android)

Add in build.gradle :

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    api 'com.github.YvesCheung.EmojiReade:lib-jvm:x.y.z'
}

Source Code

https://github.com/YvesCheung/EmojiReader