Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omnidan/node-emoji
š simple emoji support for node.js projects
https://github.com/omnidan/node-emoji
emoji emoji-support javascript node node-emoji nodejs
Last synced: 5 days ago
JSON representation
š simple emoji support for node.js projects
- Host: GitHub
- URL: https://github.com/omnidan/node-emoji
- Owner: omnidan
- License: mit
- Created: 2014-08-13T12:17:54.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2024-10-08T13:54:03.000Z (26 days ago)
- Last Synced: 2024-10-18T12:19:55.030Z (16 days ago)
- Topics: emoji, emoji-support, javascript, node, node-emoji, nodejs
- Language: TypeScript
- Homepage:
- Size: 849 KB
- Stars: 1,309
- Watchers: 11
- Forks: 241
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
- awesome-fonts - node-emoji - Simple emoji support for Node.js (Emojis)
- awesome-typography - node-emoji - š simple emoji support for Node.js projects. (JavaScript)
- awesome-starred - omnidan/node-emoji - :smirk: simple emoji support for node.js projects (nodejs)
README
node-emoji
Friendly emoji lookups and parsing utilities for Node.js. š
`node-emoji` provides a fun, straightforward interface on top of the following excellent libraries:
- [`emojilib`](https://npmjs.org/package/emojilib): provides a list of emojis and keyword search on top of it
- [`skin-tone`](https://npmjs.org/package/skin-tone): parses out base emojis from skin tones## Install
```sh
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](https://github.com/omnidan/node-emoji/tree/legacy).
## Usage
```js
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') // falseemoji.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.
1. **`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.```js
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.
```js
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.
```js
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.
```js
import * as emoji from 'node-emoji'console.log(emoji.has('š¦'))
// true
```### emoji.random()
Get a random emoji.
```js
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.```js
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.
```js
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.
1. **`options`** _(optional)_:- **`preserveSpaces`** (`boolean`): Whether to keep the extra space after a stripped emoji.
```js
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.
```js
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.
1. **`options`** _(optional)_:
- **`markdown`** (`boolean`; default: `false`): Whether to return a `":emoji:"` string instead of `"emoji"````js
import * as emoji from 'node-emoji'console.log(emoji.which('š¦'))
// 'unicorn'
```## Development
See _[`.github/Development.md`](./github/Development.md)_.
## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fomnidan%2Fnode-emoji.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fomnidan%2Fnode-emoji?ref=badge_large)
### Special Thanks
...to Anand Chowdhary (@AnandChowdhary) and his company [Pabio](https://github.com/pabio) for sponsoring this project via [GitHub Sponsors](https://github.com/sponsors/omnidan)!
## Contributors
./cĀ²
š»
Adam Skoufis
š»
Adrian Carolli
š»
Alex Litel
š»
Alex Rudenko
š»
Antoine Hanriat
š»
Daniel Bugl
š š» š š¤ š š§ š§
Daniel Hilton
š»
Elizabeth
š» š§
Gabriel Csapo
š»
Greenkeeper
š»
Josh Goldberg āØ
š§ š» š š§
Kevin Cooper
š»
Kristoffer K.
š»
Ludo Renzetti
š»
Nicolas Charpentier
š§
Nicolas Gryman
š»
Paul Barber
š»
Richie Bendall
š» š§
Ritik Banger
š»
Roopak Venkatakrishnan
š»
Shivkanth Bagavathy
š»
Siddharth Batra
š»
Stephan Meijer
š»
Thomas Beverley
š
Tim Ruffles
š»
Todd Mazierski
š
fossabot
š»
goodjun
š
jackie luo
š»
tgbtyty
š»
wtgtybhertgeghgtwtg
š»