Socket
Socket
Sign inDemoInstall

node-emoji

Package Overview
Dependencies
5
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-emoji

Friendly emoji lookups and parsing utilities for Node.js. πŸ’–


Version published
Weekly downloads
5.3M
increased by1.9%
Maintainers
3
Install size
446 kB
Created
Weekly downloads
Β 

Package description

What is node-emoji?

The node-emoji package provides a simple way to add Unicode emoji support to your Node.js applications. It allows you to easily include emoji characters in your strings and manipulate them as needed.

What are node-emoji's main functionalities?

Get emoji by name

Retrieve an emoji character using its name (alias).

const emoji = require('node-emoji');
console.log(emoji.get('coffee')); // outputs the coffee emoji

Find emoji in a string

Search for and return information about an emoji within a string.

const emoji = require('node-emoji');
console.log(emoji.find('I :heart: node-emoji!')); // finds and returns the heart emoji object

Replace emoji names with characters in a string

Convert emoji aliases in a string to their corresponding emoji characters.

const emoji = require('node-emoji');
console.log(emoji.emojify('I :heart: node-emoji!')); // replaces the :heart: alias with the actual heart emoji character

Replace characters with emoji names in a string

Convert emoji characters in a string to their corresponding emoji aliases.

const emoji = require('node-emoji');
console.log(emoji.unemojify('I ❀️ node-emoji!')); // replaces the heart emoji character with its alias :heart:

Random emoji

Get a random emoji object, which includes the emoji character and its alias.

const emoji = require('node-emoji');
console.log(emoji.random()); // returns a random emoji object

Other packages similar to node-emoji

Readme

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:

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

FAQs

Last updated on 20 Nov 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc