• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Dec-2021-

lib/H03-May-2022-11

LICENSEH A D18-Dec-20211.1 KiB2117

README.mdH A D18-Dec-20214.6 KiB8057

package.jsonH A D18-Dec-20211 KiB4342

README.md

1# node-emoji
2
3[![NPM version (1.0.3)](https://img.shields.io/npm/v/node-emoji.svg?style=flat-square)](https://www.npmjs.com/package/node-emoji) [![NPM Downloads](https://img.shields.io/npm/dm/node-emoji.svg?style=flat-square)](https://www.npmjs.com/package/node-emoji) [![Build Status](https://img.shields.io/travis/omnidan/node-emoji/master.svg?style=flat-square)](https://travis-ci.org/omnidan/node-emoji) [![Dependencies](https://img.shields.io/david/omnidan/node-emoji.svg?style=flat-square)](https://david-dm.org/omnidan/node-emoji) [![Code Climate](https://img.shields.io/codeclimate/github/omnidan/node-emoji.svg?style=flat-square)](https://codeclimate.com/github/omnidan/node-emoji) [![https://paypal.me/DanielBugl/9](https://img.shields.io/badge/donate-paypal-yellow.svg?style=flat-square)](https://paypal.me/DanielBugl/9)
4
5_simple emoji support for node.js projects_
6
7![node-emoji example](https://i.imgur.com/yIo5Uux.png)
8
9**Help wanted:** We are looking for volunteers to maintain this project, if you are interested, feel free to contact me at [me@omnidan.net](mailto:me@omnidan.net)
10
11## Installation
12To install `node-emoji`, you need [node.js](http://nodejs.org/) and [npm](https://github.com/npm/npm#super-easy-install). :rocket:
13
14Once you have that set-up, just run `npm install --save node-emoji` in your project directory. :ship:
15
16You're now ready to use emoji in your node projects! Awesome! :metal:
17
18## Usage
19```javascript
20var emoji = require('node-emoji')
21emoji.get('coffee') // returns the emoji code for coffee (displays emoji on terminals that support it)
22emoji.which(emoji.get('coffee')) // returns the string "coffee"
23emoji.get(':fast_forward:') // `.get` also supports github flavored markdown emoji (http://www.emoji-cheat-sheet.com/)
24emoji.emojify('I :heart: :coffee:!') // replaces all :emoji: with the actual emoji, in this case: returns "I ❤️ ☕️!"
25emoji.random() // returns a random emoji + key, e.g. `{ emoji: '❤️', key: 'heart' }`
26emoji.search('cof') // returns an array of objects with matching emoji's. `[{ emoji: '☕️', key: 'coffee' }, { emoji: ⚰', key: 'coffin'}]`
27emoji.unemojify('I ❤️ ��') // replaces the actual emoji with :emoji:, in this case: returns "I :heart: :pizza:"
28emoji.find('��') // Find the `pizza` emoji, and returns `({ emoji: '��', key: 'pizza' })`;
29emoji.find('pizza') // Find the `pizza` emoji, and returns `({ emoji: '��', key: 'pizza' })`;
30emoji.hasEmoji('��') // Validate if this library knows an emoji like `��`
31emoji.hasEmoji('pizza') // Validate if this library knowns a emoji with the name `pizza`
32emoji.strip('⚠️ 〰️ 〰️ low disk space') // Strips the string from emoji's, in this case returns: "low disk space".
33emoji.replace('⚠️ 〰️ 〰️ low disk space', (emoji) => `${emoji.key}:`) // Replace emoji's by callback method: "warning: low disk space"
34```
35
36## Options
37
38### onMissing
39`emoji.emojify(str, onMissing)`
40
41As second argument, `emojify` takes an handler to parse unknown emojis. Provide a function to add your own handler:
42
43```js
44var onMissing = function (name) {
45  return name;
46});
47
48var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', onMissing);
49// emojified: I unknown_emoji ⭐️ another_one
50```
51
52### format
53`emoji.emojify(str, onMissing, format)`
54
55As third argument, `emojify` takes an handler to wrap parsed emojis. Provide a function to place emojis in custom elements, and to apply your custom styling:
56
57```js
58var format = function (code, name) {
59  return '<img alt="' + code + '" src="' + name + '.png" />';
60});
61
62var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', null, format);
63// emojified: I <img alt="❤️" src="heart.png" /> <img alt="☕️" src="coffee.png" />
64```
65
66## Adding new emoji
67Emoji come from js-emoji (Thanks a lot :thumbsup:). You can get a JSON file with all emoji here: https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json
68
69To update the list or add custom emoji, clone this repository and put them into `lib/emojifile.js`.
70Then run `npm run-script emojiparse` in the project directory or `node emojiparse` in the lib directory.
71This should generate the new emoji.json file and output `Done.`.
72
73That's all, you now have more emoji you can use! :clap:
74
75## Support / Donations
76If you want to support node-emoji development, please consider donating (it helps me keeping my projects active and alive!):
77
78 * Paypal: [![daniel.bugl@gmail.com](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YBMS9EKTNPZHJ)
79 * Bitcoin: [1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA](bitcoin:1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA)
80