Transform emoji shortcodes like :thumbs_up: into emoji characters.
npm install @dev-kas/emoji-shortcode-transformconst { transform, suggest } = require("@dev-kas/emoji-shortcode-transform");
transform("ship it :thumbs_up:");
// "ship it 👍"
suggest("ship it :thu", 12);
// ["thumbs_up", "thumbs_down"]import { transform, suggest } from "@dev-kas/emoji-shortcode-transform";
transform("that is :fire:");
// "that is 🔥"
suggest("that is :fi", 11);
// ["fire"]Use createEmojiTransform when you want to provide your own shortcode map
instead of the built-in one.
import { createEmojiTransform } from "@dev-kas/emoji-shortcode-transform";
const emoji = createEmojiTransform({
party: "🎉",
ship: "🚢",
});
emoji.transform("release :party:");
// "release 🎉"
emoji.suggest("release :shi", 12);
// ["ship"]The CommonJS build also exposes browser globals when loaded with a script tag.
<script src="./index.js"></script>
<script>
window.transform("nice :cool:");
window.suggest("nice :co", 8);
</script>Returns a string with complete known shortcodes replaced by emoji. Unknown, escaped, and incomplete shortcodes are preserved.
Returns shortcode names that match the active :shortcode before cursor.
Prefix matches are ranked first, then close fuzzy matches.
Returns { transform, suggest } functions backed by emojiMap.
npm testISC. In practical terms, the ISC license is a permissive open source license: you can use, copy, modify, and distribute the software, including in proprietary projects, as long as the copyright notice and license text are included. It also disclaims warranties and liability from the author. See LICENSE for the full legal text.