node-emoji
simple emoji support for node.js projects
Help wanted: We are looking for volunteers to maintain this project, if you are interested, feel free to contact me at me@omnidan.net
Installation
To install node-emoji
, you need node.js and npm. :rocket:
Once you have that set-up, just run npm install --save node-emoji
in your project directory. :ship:
You're now ready to use emoji in your node projects! Awesome! :metal:
Usage
var emoji = require('node-emoji')
emoji.get('coffee')
emoji.which(emoji.get('coffee'))
emoji.get(':fast_forward:')
emoji.emojify('I :heart: :coffee:!')
emoji.random()
emoji.search('cof')
emoji.unemojify('I ❤️ 🍕')
emoji.find('🍕')
emoji.find('pizza')
emoji.hasEmoji('🍕')
emoji.hasEmoji('pizza')
emoji.strip('⚠️ 〰️ 〰️ low disk space')
emoji.replace('⚠️ 〰️ 〰️ low disk space', (emoji) => `${emoji.key}:`)
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 onMissing = function (name) {
return name;
});
var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', onMissing);
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 format = function (code, name) {
return '<img alt="' + code + '" src="' + name + '.png" />';
});
var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', null, format);
Adding new emoji
Emoji come from js-emoji (Thanks a lot :thumbsup:). You can get a JSON file with all emoji here: https://raw.githubusercontent.com/omnidan/node-emoji/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! :clap:
Support / Donations
If you want to support node-emoji development, please consider donating (it helps me keeping my projects active and alive!):