Skip to main content
Deno 2 is finally here 🎉️
Learn more

github-emoji

jsr denoland deno doc Test

GitHub emoji library for TypeScript.

Usage

Get a emoji string of a name (e.g. smile), use emojiOf function like:

import { emojiOf } from "https://deno.land/x/github_emoji@v1.0.0/mod.ts";

console.log(emojiOf("smile"));
// -> ☺️

The emojiOf require EmojiName instead of string so invalid emoji name become TypeScript error.

import {
  EmojiName,
  emojiOf,
} from "https://deno.land/x/github_emoji@v1.0.0/mod.ts";

console.log(emojiOf("smile")); // OK
//console.log(emojiOf("this-is-not-valid-emoji-name")); // TypeScript error
console.log(emojiOf("this-is-not-valid-emoji-name" as EmojiName)); // OK but returns undefined

Replace all valid :{name}: like strings (e.g. :smile:) in a text with emoji strings, use emojify function like:

import { emojify } from "https://deno.land/x/github_emoji@v1.0.0/mod.ts";

console.log(emojify("Hello :world: :smile:")); // :world: is not valid emoji
// -> Hello :world: ☺️

See API documentation for more details and functions.

License

The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.

Special Thanks

This library is strongly inspired by rhysd/node-github-emoji.