Socket
Book a DemoInstallSign in
Socket

node-emoji

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-emoji

Friendly emoji lookups and parsing utilities for Node.js. 💖

latest
Source
npmnpm
Version
2.2.0
Version published
Weekly downloads
4.8M
-11.51%
Maintainers
2
Weekly downloads
 
Created
Source

node-emoji

Friendly emoji lookups and parsing utilities for Node.js. 💖

All Contributors: 32 👪 Codecov Test Coverage Contributor Covenant License: MIT Sponsor: On GitHub Style: Prettier TypeScript: Strict npm package version Contributor Covenant

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

Install

npm install 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:

  • input (string): The input string containing the markdown-encoding emojis.
  • 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:

  • 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:

  • 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:

  • 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:

  • 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:

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

  • 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:

  • 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:

  • emoji (string): The emoji to get the name of.
  • 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 for sponsoring this project via GitHub Sponsors!

Contributors

./c²
./c²

💻
Adam Skoufis
Adam Skoufis

💻
Adrian Carolli
Adrian Carolli

💻
Alex Litel
Alex Litel

💻
Alex Rudenko
Alex Rudenko

💻
Antoine Hanriat
Antoine Hanriat

💻
Daniel Bugl
Daniel Bugl

🐛 💻 🔍 🤔 🚇 🔧 🚧
Daniel Hilton
Daniel Hilton

💻
Elizabeth
Elizabeth

💻 🚧
Gabriel Csapo
Gabriel Csapo

💻
Greenkeeper
Greenkeeper

💻
Josh Goldberg ✨
Josh Goldberg ✨

🔧 💻 🚇 🚧
Kevin Cooper
Kevin Cooper

💻
Kristoffer K.
Kristoffer K.

💻
Ludo Renzetti
Ludo Renzetti

💻
Nicolas Charpentier
Nicolas Charpentier

🚧
Nicolas Gryman
Nicolas Gryman

💻
Paul Barber
Paul Barber

💻
Richie Bendall
Richie Bendall

💻 🚧
Ritik Banger
Ritik Banger

💻
Roopak Venkatakrishnan
Roopak Venkatakrishnan

💻
Shivkanth Bagavathy
Shivkanth Bagavathy

💻
Siddharth Batra
Siddharth Batra

💻
Stephan Meijer
Stephan Meijer

💻
Thomas Beverley
Thomas Beverley

🐛
Tim Ruffles
Tim Ruffles

💻
Todd Mazierski
Todd Mazierski

🐛
fossabot
fossabot

💻
goodjun
goodjun

🐛
jackie luo
jackie luo

💻
tgbtyty
tgbtyty

💻
wtgtybhertgeghgtwtg
wtgtybhertgeghgtwtg

💻

Keywords

emoji

FAQs

Package last updated on 03 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts