1.0.6 โ€ข Published 1 year ago

emoji-provider v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

emoji-provider

Adds a simple way of generating emojis to your front-end application. Do you need emojis for a chat application? Maybe you want to convert emoticons to emojis in text? Look no further! Currently supports emojis up to Unicode Version 15.

A zero-dependency library.

Installation

Install with npm:

npm install emoji-provider

ES6

import { emojiProvider } from 'emoji-provider'

Usage example

import { emojiProvider } from 'emoji-provider'

const text = 'I love emojis :D <3'
const emojiText = emojiProvider.replaceEmoticonsWithEmojis(text)

console.log(emojiText)
// => 'I love emojis ๐Ÿ˜ƒ โค๏ธ'

API

getEmojis()

Returns a string array with all supported emojis (currently supports emojis up to Unicode Version 15).

const emojis = getEmojis()

console.log(emojis)
/* => [
  '๐Ÿ˜€', '๐Ÿ˜ƒ', '๐Ÿ˜„', '๐Ÿ˜', '๐Ÿ˜†', '๐Ÿ˜…', '๐Ÿคฃ',
  '๐Ÿ˜‚', '๐Ÿ™‚', '๐Ÿ™ƒ', '๐Ÿ˜‰', '๐Ÿ˜Š', '๐Ÿ˜‡', '๐Ÿฅฐ',
  '๐Ÿ˜', '๐Ÿคฉ', '๐Ÿ˜˜', '๐Ÿ˜—', '๐Ÿ˜š', '๐Ÿ˜™', '๐Ÿ˜‹',
  '๐Ÿ˜›', '๐Ÿ˜œ', '๐Ÿคช', '๐Ÿ˜', '๐Ÿค‘', '๐Ÿค—', '๐Ÿคญ',
  '๐Ÿคซ', '๐Ÿค”', '๐Ÿค', '๐Ÿคจ', '๐Ÿ˜', '๐Ÿ˜‘', '๐Ÿ˜ถ',
  '๐Ÿ˜', '๐Ÿ˜’', '๐Ÿ™„', '๐Ÿ˜ฌ', '๐Ÿคฅ', '๐Ÿ˜Œ', '๐Ÿ˜”', 
  '๐Ÿ˜ช', '๐Ÿคค', '๐Ÿ˜ด', '๐Ÿ˜ท', '๐Ÿค’', ... 
]
*/

getEmojisAndTags()

Returns an object array with all supported emojis and corresponding tags (currently supports emojis up to Unicode Version 15).

const emojiObjects = getEmojisAndTags()

console.log(emojiObjects)
/* => [
  { tag: 'happy-face', emoji: '๐Ÿ˜€' }, 
  { tag: 'happy-face-with-big-eyes', emoji: '๐Ÿ˜ƒ' } ,
  { tag: 'happy-face-with-smiling-eyes', emoji: '๐Ÿ˜„' },
  { tag: 'beaming-face-with-smiling-eyes', emoji: '๐Ÿ˜' },
  { tag: 'laughing', emoji: '๐Ÿ˜†' },
  { tag: 'happy-sweat', emoji: '๐Ÿ˜…' },
  { tag: 'rolling-on-the-floor-laughing', emoji: '๐Ÿคฃ' },
  { tag: 'face-with-tears-of-joy', emoji: '๐Ÿ˜‚' },
  { tag: 'slightly-smiling-face', emoji: '๐Ÿ™‚' },
  { tag: 'upside-down-face', emoji: '๐Ÿ™ƒ' },
  { tag: 'winking-face', emoji: '๐Ÿ˜‰' },
  { tag: 'smiley-face', emoji: '๐Ÿ˜Š' },
  { ... } 
*/

getEmojisByCategory(...categories)

Returns a string array with emojis of chosen categories.

Allowed input string arguments:

  • activity
  • animalsAndNature
  • flags
  • foodAndDrink
  • objects
  • peopleAndBody
  • smileysAndEmotion
  • symbols
  • travelAndPlaces

OBS! Arguments are case sensitive and need to be exact.

const emojis = getEmojisByCategory('foodAndDrink')

console.log(emojis)
/* => [
  '๐Ÿ‡', '๐Ÿˆ', '๐Ÿ‰', '๐ŸŠ', '๐Ÿ‹', '๐ŸŒ', '๐Ÿ', '๐Ÿฅญ', 
  '๐ŸŽ', '๐Ÿ', '๐Ÿ', '๐Ÿ‘', '๐Ÿ’', '๐Ÿ“', '๐Ÿฅ', '๐Ÿ…', 
  '๐Ÿฅฅ', '๐Ÿฅ‘', '๐Ÿ†', '๐Ÿฅ”', '๐Ÿฅ•', '๐ŸŒฝ', '๐ŸŒถ', '๐Ÿฅ’', 
  '๐Ÿฅฌ', '๐Ÿฅฆ', '๐Ÿฅœ', '๐Ÿž', '๐Ÿฅ', '๐Ÿฅ–', '๐Ÿฅจ', '๐Ÿฅฏ', 
  '๐Ÿฅž', '๐Ÿง€', '๐Ÿ–', '๐Ÿ—', '๐Ÿฅฉ', '๐Ÿฅ“', '๐Ÿ”', '๐ŸŸ',
  '๐Ÿ•', '๐ŸŒญ', '๐Ÿฅช', '๐ŸŒฎ', '๐ŸŒฏ', '๐Ÿฅ™', '๐Ÿฅš', '๐Ÿณ',
  '๐Ÿฅ˜', '๐Ÿฒ', '๐Ÿฅฃ', '๐Ÿฅ—', '๐Ÿฟ', '๐Ÿง‚', '๐Ÿฅซ', '๐Ÿฑ',
  '๐Ÿ˜', '๐Ÿ™', '๐Ÿš', '๐Ÿ›', '๐Ÿœ', '๐Ÿ', '๐Ÿ ', '๐Ÿข', 
  '๐Ÿฃ', '๐Ÿค', '๐Ÿฅ', '๐Ÿฎ', '๐Ÿก', '๐ŸฅŸ', '๐Ÿฅ ', '๐Ÿฅก', 
  '๐Ÿฆ', '๐Ÿง', '๐Ÿจ', '๐Ÿฉ', ... 
  ]
*/

getEmojisAndTagsByCategory(...categories)

Returns an object array with emojis and tags of chosen categories.

Allowed input string arguments:

  • activity
  • animalsAndNature
  • flags
  • foodAndDrink
  • objects
  • peopleAndBody
  • smileysAndEmotion
  • symbols
  • travelAndPlaces

OBS! Arguments are case sensitive and need to be exact.

const emojiObjects = getEmojisObjectsByCategory('animalAndNature', 'peopleAndBody')

console.log(emojiObjects)
/* => [
  { tag: 'see-no-evil-monkey', emoji: '๐Ÿ™ˆ' },
  { tag: 'hear-no-evil-monkey', emoji: '๐Ÿ™‰' },
  { tag: 'speak-no-evil-monkey', emoji: '๐Ÿ™Š' },
  { tag: 'monkey-face', emoji: '๐Ÿต' },
  { tag: 'monkey', emoji: '๐Ÿ’' },
  { tag: 'gorilla', emoji: '๐Ÿฆ' },
  { tag: 'dog-face', emoji: '๐Ÿถ' },
  { tag: 'dog', emoji: '๐Ÿ•' },
  { tag: 'poodle', emoji: '๐Ÿฉ' },
  { ... }
  { tag: 'waiving-hand', emoji: '๐Ÿ‘‹' },
  { tag: 'raised-back-of-hand', emoji: '๐Ÿคš' },
  { tag: 'raised-hand', emoji: 'โœ‹' },
  { tag: 'vulcan-salute', emoji: '๐Ÿ––'},
  { tag: 'ok-hand', emoji: '๐Ÿ‘Œ' },
  { tag: 'fingers-crossed', emoji: '๐Ÿคž' },
  { tag: 'i-love-you-hand-sign', emoji: '๐ŸคŸ' },
  { tag: 'heavy-metal-hand-sign', emoji: '๐Ÿค˜' },
  { tag: 'call-me-hand-sign', emoji: '๐Ÿค™' },
  { ... }
]
*/

getEmojiByTag(tag)

Returns the emoji as a string.

const emoji = getEmojiByTag(piano)

console.log(emoji)
// => '๐ŸŽน'

replaceEmoticonsWithEmojis(text)

Returns a new string with emoticons replaced with emojis.

const newText = replaceEmoticonsWithEmojis('Hi! :D How Are you? :)')

console.log(newText)
// => 'Hi! ๐Ÿ˜ƒ How Are you? ๐Ÿ˜Š'

getMatchingEmojis(text)

Returns an array with emojis matching input.

const emojis = getMatchingEmojis('sad')

console.log(emojis)
// => [ '๐Ÿ˜ข', '๐Ÿ˜ž', '๐Ÿ˜“', '๐Ÿ˜ฟ' ]

Want to contribute?

See DEVELOPER.md for project information and contribution details.