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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gh-emoji

v0.2.5

Published

Github emoji parsing done right

Downloads

612

Readme

gh-emoji Build Status npm version Bower version Dependency Status npm license DEMO

Github emoji parsing done right 👍🙌👋👏💩🙋😈😄👶🙇👱🍔🍕👻💅👹🚲🚂

Gh-emoji aims to be the simplest Github emoji parser. It's built on the top of the Github Emoji Api with no dependencies and having a couple of functions as public api.

Installation

$ npm i gh-emoji

$ bower i gh-emoji

Usage

import { load, parse } from 'gh-emoji'

load().then(() => {
  const editor = document.getElementById('editor');
  const preview = document.getElementById('preview');

  preview.innerHTML = parse(editor.value);
});

Demo

Take a look at the online demo

API

all

src/index.js:89-91

Return all fetched emojis.

Examples

import { load as loadEmojis, all as allEmojis } from 'gh-emoji';

loadEmojis().then(() => {
  console.log(allEmojis()); // {emojiName: emojiImageTag}
});

Returns Object Object with emoji names as keys and generated image tags as values.

exist

src/index.js:108-116

Check if requested emoji exists.

Parameters

Examples

import { load as loadEmojis, exist as emojiExists } from 'gh-emoji';

loadEmojis().then(() => {
  console.log(emojiExists('foo')); // false
  console.log(emojiExists('smile')); // true
});

Returns Boolean

find

src/index.js:48-50

Return array with matched emojis in text.

Parameters

  • text String Text to search for emojis.

Examples

import { load as loadEmojis, find as findEmojis } from 'gh-emoji';

const text = 'Do you believe in :alien:...? :scream:';

loadEmojis().then((emojis) => {
  console.log(findEmojis(text)); // [':alien:', ':scream:']
});

Returns Array.<String> Array with matched emojis.

getUrl

src/index.js:132-140

Return github's image url of emoji.

Parameters

Examples

import { load as loadEmojis, getUrl } from 'gh-emoji';

loadEmojis().then(() => {
  console.log(getUrl('apple')); // 'https://assets-cdn.github.com/images/icons/emoji/unicode/1f34e.png?v6'
});

Returns String Image url of given emoji.

load

src/index.js:65-74

Fetch the emoji data from Github's api.

Examples

import { load as loadEmojis } from 'gh-emoji';

loadEmojis().then((emojis) => {
  console.log(emojis['+1']); // 👍
});

Returns Promise.<Object> Promise which passes Object with emoji names as keys and generated image tags as values to callback.

parse

src/index.js:161-185

Parse text and replace emoji tags with actual emoji symbols.

Parameters

  • text String Text to parse.
  • options Object Options with additional data for parser.
    • options.classNames String String with custom class names added to each emoji, separated with whitespace.

Examples

import { load as loadEmojis, parse } from 'gh-emoji';

const text = 'Do you believe in :alien:...? :scream:';

loadEmojis().then(() => {
  console.log(parse(text)) // 'Do you believe in 👽...? 😱';
});

Returns String Parsed text with emoji image tags in it.

References

  • Github Emoji Api docs: https://developer.github.com/v3/emojis/
  • Github Emoji Api: https://api.github.com/emojis
  • All Github Emoji icons: https://github.com/scotch-io/All-Github-Emoji-Icons

Browser Support

| | | | | | |:---:|:---:|:---:|:---:|:---:| | Latest ✔ | Latest ✔ | IE 9+ ✔ | Latest ✔ | Latest ✔ |

License

MIT License © zzarcon