• Stars
    star
    1,270
  • Rank 35,673 (Top 0.8 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated 2 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,897
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

now

โœจ simple real-time reddit/HN-inspired social network crafted with React and Meteor
JavaScript
4
star
13

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
14

ZenHubPlus

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

log-simple

๐Ÿ’ฌ Super Simple JavaScript Logging
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

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
27

tn2_core

The core system for the new TouchNet 2.X
C++
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