What is emojilib?
The emojilib npm package is a library that provides a comprehensive list of emoji keywords and their corresponding emoji characters. It is useful for applications that need to display, search, or categorize emojis based on keywords.
What are emojilib's main functionalities?
Get Emoji by Keyword
This feature allows you to retrieve an emoji object by its keyword. The object contains the emoji character, associated keywords, and other metadata.
const emojilib = require('emojilib');
const emoji = emojilib.lib['grinning'];
console.log(emoji); // Output: { keywords: [ 'face', 'smile', 'happy', 'joy', 'kawaii' ], char: '😀', fitzpatrick_scale: false, category: 'people' }
List All Emojis
This feature allows you to list all available emojis in the library. It maps through the emoji library and extracts the emoji characters.
const emojilib = require('emojilib');
const allEmojis = Object.keys(emojilib.lib).map(key => emojilib.lib[key].char);
console.log(allEmojis); // Output: Array of all emoji characters
Search Emojis by Keyword
This feature allows you to search for emojis by a specific keyword. It filters the emoji library based on the presence of the keyword in the emoji's keywords array.
const emojilib = require('emojilib');
const searchEmojis = (keyword) => {
return Object.keys(emojilib.lib).filter(key => emojilib.lib[key].keywords.includes(keyword)).map(key => emojilib.lib[key].char);
};
console.log(searchEmojis('happy')); // Output: Array of emojis related to 'happy'
Other packages similar to emojilib
emoji-dictionary
The emoji-dictionary package provides a simple way to get emoji characters by name and vice versa. It is similar to emojilib but focuses more on direct name-to-emoji and emoji-to-name conversions.
node-emoji
The node-emoji package offers a straightforward API to get emoji characters by name, replace emoji names in a string with actual emojis, and more. It is more focused on string manipulation involving emojis compared to emojilib.
emojione
The emojione package provides a comprehensive set of emoji assets and a library to convert emoji shortcodes, unicode, and ASCII emoticons into emoji images. It offers more extensive functionality for rendering and displaying emojis compared to emojilib.
emojilib
Make emoji searchable with this keyword library.
Install
npm install emojilib --save
Usage
> require("emojilib")
{
'😀': [
'grinning_face',
'face',
'smile',
'happy',
'joy',
':D',
'grin'
],
'😃': [
'grinning_face_with_big_eyes',
'face',
'happy',
'joy',
'haha',
...
}
If you are looking for the unicode emoji dataset, including version, grouping, ordering, and skin tone support flag, check out unicode-emoji-json
.
Migrating from 2.x
Previously:
> var emoji = require("emojilib")
> emoji.lib
{
"grinning": {
"keywords": ["face", "smile", "happy", "joy"],
"char": "😀",
"fitzpatrick_scale": false,
"category": "people"
},
...
}
Now, merge keywords with other metadata from unicode-emoji-json
:
> var data = require('unicode-emoji-json')
> var keywordSet = require('emojilib')
> for (const emoji in data) {
data[emoji]['keywords'] = keywordSet[emoji]
}
> data['😀']
{
name: 'grinning face',
slug: 'grinning_face',
group: 'Smileys & Emotion',
emoji_version: '1.0',
unicode_version: '1.0',
skin_tone_support: false,
keywords: [ 'grinning_face', 'face', 'smile', 'happy', 'joy', ':D', 'grin' ]
}
Previously:
> var emoji = require("emojilib")
> emoji.ordered
[ 'grinning', 'grimacing', 'grin', 'joy', 'smiley', 'smile', 'sweat_smile', ...]
Now this data can be found in unicode-emoji-json
:
> var orderedEmoji = require('unicode-emoji-json/data-ordered-emoji')
['😀', '😃', '😄', '😁', '😆', '😅',...]
Previously:
> var emoji = require("emojilib")
> emoji.fitzpatrick_scale_modifiers
[ '🏻', '🏼', '🏽', '🏾', '🏿' ]
Now this data can be found in unicode-emoji-json
:
> require('unicode-emoji-json/data-emoji-components')
{
light_skin_tone: '🏻',
medium_light_skin_tone: '🏼',
medium_skin_tone: '🏽',
medium_dark_skin_tone: '🏾',
dark_skin_tone: '🏿',
red_hair: '🦰',
curly_hair: '🦱',
white_hair: '🦳',
bald: '🦲'
}
Previously:
> require("emojilib").lib['v'].fitzpatrick_scale
true
> require("emojilib").lib['turtle'].fitzpatrick_scale
false
Now this data can be found in unicode-emoji-json
:
> require('unicode-emoji-json')['✌️'].skin_tone_support
true
> require('unicode-emoji-json')['🐢'].skin_tone_support
false
Development
See CONTRIBUTING.md
.