emoji-node
simple emoji support for node.js projects
Installation
To install emoji-node
, you need node.js and npm. 🚀
Once you have that set-up, just run npm install --save emoji-node
or yarn add emoji-node
in your project directory. 🚢
You're now ready to use emoji in your node projects! Awesome! 🤘
Usage
var emoji = emoji // returns the emoji code for coffee (displays emoji on terminals that support it)emoji // returns the string "coffee"emoji // `.get` also supports github flavored markdown emoji (http://www.emoji-cheat-sheet.com/)emoji //❤️emoji //😄emoji // replaces all :emoji: with the actual emoji, in this case: returns "I ❤️ ☕️!"emoji // replace almost all shorthand emoji support 😄 😘 ❤️ 😙 😆 👍 😑 😄 😉 😛 👼 😕 😢 😈emoji // returns a random emoji + key, e.g. `{ emoji: '❤️', key: 'heart' }`emoji // returns an array of objects with matching emoji's. `[{ emoji: '☕️', key: 'coffee' }, { emoji: ⚰', key: 'coffin'}]`emoji // replaces the actual emoji with :emoji:, in this case: returns "I :heart: :pizza:"emoji // Find the `pizza` emoji, and returns `({ emoji: '🍕', key: 'pizza' })`;emoji // Find the `pizza` emoji, and returns `({ emoji: '🍕', key: 'pizza' })`;emoji // Validate if this library knows an emoji like `🍕`emoji // Validate if this library knowns a emoji with the name `pizza`emoji // Strips the string from emoji's, in this case returns: "low disk space".emoji // Replace emoji's by callback method: "warning: low disk space"
Options
onMissing
emoji.emojify(str, onMissing)
As second argument, emojify
takes an handler to parse unknown emojis. Provide a function to add your own handler:
var { return name;}); var emojified = emoji;// emojified: I unknown_emoji ⭐️ another_one
format
emoji.emojify(str, onMissing, format)
As third argument, emojify
takes an handler to wrap parsed emojis. Provide a function to place emojis in custom elements, and to apply your custom styling:
var { return '<img alt="' + code + '" src="' + name + '.png" />';}); var emojified = emoji;// emojified: I <img alt="❤️" src="heart.png" /> <img alt="☕️" src="coffee.png" />
Adding new emoji
Emoji come from js-emoji (Thanks a lot 👍). You can get a JSON file with all emoji here: https://raw.githubusercontent.com/wadehrarshpreet/emoji-node/master/lib/emoji.json
To update the list or add custom emoji, clone this repository and put them into lib/emojifile.js
.
Then run npm run-script emojiparse
in the project directory or node emojiparse
in the lib directory.
This should generate the new emoji.json file and output Done.
.
That's all, you now have more emoji you can use! 👏