• Stars
    star
    1,307
  • Rank 35,997 (Top 0.8 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ’– simple emoji support for node.js projects

node-emoji

NPM Version NPM Downloads https://github.com/sponsors/omnidan

Friendly emoji lookups and parsing utilities for Node.js ✨

node-emoji provides a fun, straightforward interface on top of the following excellent libraries:

  • emojilib: provides a list of emojis and keyword search on top of it
  • skin-tone: parses out base emojis from skin tones

Help wanted: We are looking for volunteers to maintain this project. If you are interested, feel free to contact me at [email protected].

Install

npm install --save node-emoji

2.0 Release πŸš€

This is the new 2.0 release of node-emoji, supporting ESM, new emoji and a new API.

If you want to use the old version, please check out the legacy branch.

Usage

import * as emoji from 'node-emoji'

emoji.emojify('I :heart: :coffee:!') // 'I ❀️ β˜•οΈ!'

emoji.find('heart') // { emoji: '❀', name: 'heart' }
emoji.find('❀️') // { emoji: '❀', name: 'heart' }

emoji.get('unicorn') // πŸ¦„
emoji.get(':unicorn:') // πŸ¦„

emoji.has(':pizza:') // true
emoji.has('πŸ•') // true
emoji.has('unknown') // false

emoji.random() // { name: 'house', emoji: '🏠' }

emoji.replace('I ❀️ coffee!', 'love', { preserveSpaces: true }) // 'I love coffee!'

emoji.search(':uni:') // [ { emoji: 'πŸ¦„', name: 'unicorn' }, ... ]

emoji.strip('I ❀️ coffee!') // 'I coffee!'

emoji.unemojify('πŸ• for πŸ’ƒ') // ':pizza: for :dancer:'

emoji.which('πŸ¦„') // 'unicorn'

API

emoji.emojify(input, options?)

Parse all markdown-encoded emojis in a string.

Parameters:

  1. input (string): The input string containing the markdown-encoding emojis.
  2. options (optional):
    • fallback (string; default: ""): The string to fallback to if an emoji was not found.
    • format (() => (emoji: string, part: string, string: string) => string; default: value => value): Add a middleware layer to modify each matched emoji after parsing.
import * as emoji from 'node-emoji'

console.log(emoji.emojify('The :unicorn: is a fictitious animal.'))
// 'The πŸ¦„ is a fictitious animal.'

emoji.find(emoji)

Get the name and character of an emoji.

Parameters:

  1. emoji (string): The emoji to get the data of.
import * as emoji from 'node-emoji'

console.log(emoji.find('πŸ¦„'))
// { name: 'unicorn', emoji: 'πŸ¦„' }

emoji.get(name)

Get an emoji from an emoji name.

Parameters:

  1. name (string): The name of the emoji to get.
import * as emoji from 'node-emoji'

console.log(emoji.get('unicorn'))
// 'πŸ¦„'

emoji.has(emoji)

Check if this library supports a specific emoji.

Parameters:

  1. emoji (string): The emoji to check.
import * as emoji from 'node-emoji'

console.log(emoji.has('πŸ¦„'))
// true

emoji.random()

Get a random emoji.

import * as emoji from 'node-emoji'

console.log(emoji.random())
// { name: 'unicorn', emoji: 'πŸ¦„' }

emoji.replace(input, replacement)

Replace the emojis in a string.

Parameters:

  • input (string): The input string.
  • replacement (string | (emoji: string, index: number, string: string) => string): The character to replace the emoji with. Can be either a string or a callback that returns a string.
import * as emoji from 'node-emoji'

console.log(emoji.replace('The πŸ¦„ is a fictitious animal.', 'unicorn'))
// 'The unicorn is a fictitious animal.'

emoji.search(keyword)

Search for emojis containing the provided name in their name.

Parameters:

  1. keyword (string): The keyword to search for.
import * as emoji from 'node-emoji'

console.log(emoji.search('honey'))
// [ { name: 'honeybee', emoji: '🐝' }, { name: 'honey_pot', emoji: '🍯' } ]

emoji.strip(input, options?)

Remove all of the emojis from a string.

Parameters:

  1. input (string): The input string to strip the emojis from.

  2. options (optional):

    • preserveSpaces (boolean): Whether to keep the extra space after a stripped emoji.
import * as emoji from 'node-emoji'

console.log(emoji.strip('πŸ¦„ The unicorn is a fictitious animal.'))
// 'The unicorn is a fictitious animal.'

console.log(
  emoji.strip('πŸ¦„ The unicorn is a fictitious animal.', {
    preserveSpaces: true,
  })
)
// ' The unicorn is a fictitious animal.'

emoji.unemojify(input)

Convert all emojis in a string to their markdown-encoded counterparts.

Parameters:

  1. input (string): The input string containing the emojis.
import * as emoji from 'node-emoji'

console.log(emoji.unemojify('The πŸ¦„ is a fictitious animal.'))
// 'The :unicorn: is a fictitious animal.'

emoji.which(emoji, options?)

Get an emoji name from an emoji.

Parameters:

  1. emoji (string): The emoji to get the name of.
  2. options (optional):
    • markdown (boolean; default: false): Whether to return a ":emoji:" string instead of "emoji"
import * as emoji from 'node-emoji'

console.log(emoji.which('πŸ¦„'))
// 'unicorn'

Development

See .github/Development.md.

License

FOSSA Status

Special Thanks

... to Anand Chowdhary (@AnandChowdhary) and his company Pabio (https://github.com/pabio) for sponsoring this project via GitHub Sponsors!

More Repositories

1

redux-undo

♻️ higher order reducer to add undo/redo functionality to redux state containers
JavaScript
2,907
star
2

redux-ignore

♻️ higher-order reducer to ignore redux actions
JavaScript
843
star
3

redux-recycle

♻️ higher-order reducer to reset the redux state on certain actions
JavaScript
147
star
4

redux-undo-boilerplate

♻️ πŸ”§ a magical boilerplate with hot reloading and awesome error handlingβ„’
JavaScript
121
star
5

ArduinoPure

πŸ“Ό This is a project to achieve compiling programs for the Arduino without any external programs like the Arduino IDE. It uses all the standard programs you love so much: make, cc, ... This is also the only way I was able to flash arduino programs to microcontrollers with the stk500.
C++
14
star
6

asv

⭐ Electron / Atom Shell Version Management à la "n" and "m"
Shell
9
star
7

git-leaf

πŸƒ simple and beautiful git trees
JavaScript
8
star
8

python-latex

πŸŽ“ Python modules for LaTeX parsing and management
Python
7
star
9

node-np

🎡 standalone last.fm bot written in node.js
JavaScript
7
star
10

node-kaomoji

( Ν‘Β° ΝœΚ– Ν‘Β°) simple kaomoji support for node.js projects
HTML
6
star
11

statsbot

(telegram) message stats bot
JavaScript
5
star
12

iForceBot

[DISCONTINUED] If you want to work on it, feel free to fork and start working. An IRC bot with much power and easy-to-code modules! Daniel0108 only maintains the framework and *his* plugins. The plugin downloader and repository are not official, nor maintained by him.
Python
4
star
13

ZenHubPlus

Userstyle to make ZenHub features look more integrated on GitHub
CSS
3
star
14

log-simple

πŸ’¬ Super Simple JavaScript Logging
JavaScript
3
star
15

now

✨ simple real-time reddit/HN-inspired social network crafted with React and Meteor
JavaScript
3
star
16

karma

manage activities with a points/karma system
JavaScript
3
star
17

coffeedonate

β˜• donate a cup of coffee, because coffee == <3
JavaScript
3
star
18

tuio-to-tlay

Converting TUIO to TLay Touch events
C++
2
star
19

PyTerm

πŸ’» Yet-another simple Python Terminal simulator made to practise curses in python.
Python
2
star
20

omnidan.github.io

🌐 my website
HTML
2
star
21

tlay-touch

TLay Touch is a UDP protocol that allows you to add multitouch support to programs.
C++
2
star
22

scipy-notebook-0.18

scipy-notebook with scikit-learn 0.18
1
star
23

Arrbus

🚌 Communication with the BusPirate v3
JavaScript
1
star
24

meilog

πŸ“ƒ beautiful logging library with support for structured logs (for cloud services) and local logging with colors
JavaScript
1
star
25

tn2_manager

The manager system for the new TouchNet 2.X
C++
1
star
26

tn2_core

The core system for the new TouchNet 2.X
C++
1
star
27

dotfiles-old

πŸ’Ύ My dotfiles, mostly used to share my configuration on all my machines, but of course you can also use them.
Vim Script
1
star
28

omnidan-net

omnidan.net website
HTML
1
star
29

reddit-roulette

πŸŽͺ Chrome extension: Easily get to a random subreddit by clicking a button. Wasting time has never been so easy.
JavaScript
1
star
30

sync

TouchLay Sync - Real-time document-based data syncronisation service in NodeJS using socket.io and MongoDB.
JavaScript
1
star
31

BRUTE.PY

πŸ”§ [DISCONTINUED] If you want to work on it, feel free to fork and start working. Simple python bruteforcing script for educational and testing purposes.
Python
1
star
32

Shift

simple shift-based time scheduling for busy people
CSS
1
star