Skip to content

Emoji library that allows for searching by emoji, group or keyword πŸ”

License

Notifications You must be signed in to change notification settings

chapmankyle/emoji-set

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

emoji-set

Test Status Version Size Standard Code Style

Emoji library that contains only the emojis that work on most of the browsers and operating systems currently available πŸš€ 🌍

Finally no more οΏ½ symbols when rendering the emojis πŸ₯³

Based off emojis from emojilib and keywords from unicode-emoji-json

Install πŸ”¨

NB: EmojiSet requires Node version 14 or above.

npm install emoji-set --save

Usage πŸ’Ώ

To get started, you can import the package using two methods:

// ES6 import
import EmojiSet from 'emoji-set'

// or CommonJS import
const EmojiSet = require('emoji-set')

Methods πŸ—ƒοΈ

get(filter = {})

Returns the emojis that match the given filter. Leave the filter parameter blank to return all available emojis.

Available fields for the filter parameter include:

Field Default Description
only_emoji false true to only return the emojis, false to return the emojis and their information
by_section false true to return the emojis grouped by their section, false to return the emojis without any grouping
by_keyword false true to return the emojis grouped by their keywords, false to return the emojis without any grouping

Some examples can be seen below.

πŸ“ƒ Get all available emojis

console.log(EmojiSet.get())
/* Returns */
{
  'πŸ˜€': {
    name: 'grinning face',
    code: 'grinning_face',
    group: 'Smileys & Emotion',
    keywords: [ 'grin', 'face', 'smile', 'happy', 'joy', ':D' ]
  },
  'πŸ˜ƒ': {
    name: 'grinning face with big eyes',
    code: 'grinning_face_with_big_eyes',
    group: 'Smileys & Emotion',
    keywords: [ 'grin', 'face', 'happy', 'joy', 'haha', ':D', ':)', 'smile', 'funny' ]
  },
  'πŸ˜„': {
    name: 'grinning face with smiling eyes',
    code: 'grinning_face_with_smiling_eyes',
    group: 'Smileys & Emotion',
    keywords: [ 'grin', 'face', 'happy', 'joy', 'funny', 'haha', 'laugh', 'like', ':D', ':)' ]
  },
  ...
}

πŸ“ƒ Get all available emojis without additional information

console.log(EmojiSet.get({ only_emoji: true }))
/* Returns */
[ 'πŸ˜€', 'πŸ˜ƒ', 'πŸ˜„', ... ]

πŸ“ƒ Get emojis grouped by their section name

console.log(EmojiSet.get({ by_section: true }))
/* Returns */
{
  'Smileys & Emotion': [
    {
      emoji: 'πŸ˜€',
      name: 'grinning face',
      code: 'grinning_face',
      keywords: [ 'face', 'smile', 'happy', 'joy', ':D', 'grin' ]
    },
    {
      emoji: 'πŸ˜ƒ',
      name: 'grinning face with big eyes',
      code: 'grinning_face_with_big_eyes',
      keywords: [ 'face', 'happy', 'joy', 'haha', ':D', ':)', 'smile', 'funny' ]
    },
    ...
  ],
  'People & Body': [
    {
      emoji: 'πŸ‘‹',
      name: 'waving hand',
      code: 'waving_hand',
      keywords: [ 'hands', 'gesture', 'goodbye', 'solong', 'farewell', 'hello', 'hi', 'palm' ]
    },
    {
      emoji: '🀚',
      name: 'raised back of hand',
      code: 'raised_back_of_hand',
      keywords: [ 'fingers', 'raised', 'backhand' ]
    },
    ...
  ],
  ...
}

πŸ“ƒ Get emojis grouped by their section name, without additional information

console.log(EmojiSet.get({ by_section: true, only_emoji: true }))
/* Returns */
{
  'Smileys & Emotion': [ 'πŸ˜€', 'πŸ˜ƒ', ... ],
  'People & Body': [ 'πŸ‘‹', '🀚', ... ],
  ...
}

πŸ“ƒ Get emojis grouped by their keywords

console.log(EmojiSet.get({ by_keywords: true }))
/* Returns */
{
  ...
  'playful': {
    'πŸ˜›': {
      name: 'face with tongue',
      code: 'face_with_tongue',
      group: 'Smileys & Emotion'
    },
    '😜': {
      name: 'winking face with tongue',
      code: 'winking_face_with_tongue',
      group: 'Smileys & Emotion'
    },
    '😝': {
      name: 'squinting face with tongue',
      code: 'squinting_face_with_tongue',
      group: 'Smileys & Emotion'
    },
    'πŸ‘…': {
      name: 'tongue',
      code: 'tongue',
      group: 'People & Body'
    }
  },
  'quiet': {
    '🀫': {
      name: 'shushing face',
      code: 'shushing_face',
      group: 'Smileys & Emotion'
    },
    'πŸ”‡': {
      name: 'muted speaker',
      code: 'muted_speaker',
      group: 'Objects'
    },
    'πŸ”•': {
      name: 'bell with slash',
      code: 'bell_with_slash',
      group: 'Objects'
    },
    'πŸ“΄': {
      name: 'mobile phone off',
      code: 'mobile_phone_off',
      group: 'Symbols'
    }
  },
  ...
}

πŸ“ƒ Get emojis grouped by their keywords, without additional information

console.log(EmojiSet.get({ by_keywords: true, only_emoji: true }))
/* Returns */
{
  ...
  'playful': [ 'πŸ˜›', '😜', '😝', 'πŸ‘…' ],
  'quiet': [ '🀫', 'πŸ”‡', 'πŸ”•', 'πŸ“΄' ],
  ...
}

search(filter = {})

Searches for emojis using the given filter.

Available fields for the filter parameter include:

Field Default Description
only_emoji false true to only return the emojis, false to return the emojis and their information
by_section '' Section to return the emojis from. Some examples are: 'Objects', 'Animals & Nature' etc. Value is case-insensitive
by_keyword '' Keyword to use in the emoji search. Some examples are: 'smile', 'tada' etc. Value is case-insensitive
first_match false true to only return the first match (when using by_keyword), false to return all matches

Some examples can be seen below.

πŸ“ƒ Search for emojis that match the given section name

console.log(EmojiSet.search({ by_section: 'flags' }))
/* Returns */
[
  {
    emoji: '🏁',
    code: 'chequered_flag',
    keywords: [ 'chequered', 'flag', 'contest', 'finishline', 'race', 'gokart' ]
  },
  {
    emoji: '🚩',
    code: 'triangular_flag',
    keywords: [ 'mark', 'milestone', 'place' ]
  },
  {
    emoji: '🎌',
    code: 'crossed_flags',
    keywords: [ 'cross', 'flag', 'japanese', 'nation', 'country', 'border' ]
  },
  {
    emoji: '🏴',
    code: 'black_flag',
    keywords: [ 'black', 'flag', 'pirate' ]
  },
  {
    emoji: '🏳️' ,
    code: 'white_flag',
    keywords: [ 'white', 'flag', 'losing', 'loser', 'lost', 'surrender', 'give up', 'fail' ]
  },
  {
    emoji: 'πŸ³οΈβ€πŸŒˆ' ,
    code: 'rainbow_flag',
    keywords: [ 'rainbow', 'flag', 'pride', 'gay', 'lgbt', 'glbt', 'queer', 'homosexual', 'lesbian', 'bisexual', 'transgender' ]
  },
  {
    emoji: 'πŸ΄β€β˜ οΈ',
    code: 'pirate_flag',
    keywords: [ 'pirate', 'flag', 'skull', 'crossbones', 'banner' ]
  }
]

πŸ“ƒ Search for emojis that match the given section name, without additional information

console.log(EmojiSet.search({ by_section: 'flags', only_emoji: true }))
/* Returns */
[ '🏁', '🚩', '🎌', '🏴', '🏳️', 'πŸ³οΈβ€πŸŒˆ', 'πŸ΄β€β˜ οΈ' ]

πŸ“ƒ Search for emojis that match the given keyword

console.log(EmojiSet.search({ by_keyword: 'perf' }))
/* Returns */
{
  'πŸ’―': {
    name: 'hundred points',
    code: 'hundred_points',
    group: 'Smileys & Emotion'
  },
  'πŸ‘Œ': {
    name: 'OK hand',
    code: 'ok_hand',
    group: 'People & Body'
  },
  'πŸ‘―': {
    name: 'people with bunny ears',
    code: 'people_with_bunny_ears',
    group: 'People & Body'
  },
  '🀹': {
    name: 'person juggling',
    code: 'person_juggling',
    group: 'People & Body'
  }
}

πŸ“ƒ Search for emojis that match the given keyword, returning the first match only

console.log(EmojiSet.search({ by_keyword: 'perf', first_match: true }))
/* Returns */
{
  'πŸ’―': {
    name: 'hundred points',
    code: 'hundred_points',
    group: 'Smileys & Emotion'
  }
}

πŸ“ƒ Search for emojis that match the given keyword, returning the first match only and without any additional information

console.log(EmojiSet.search({ by_keyword: 'perf', first_match: true, only_emoji: true }))
/* Returns */
[ 'πŸ’―' ]