New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

retext-emoji

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retext-emoji

Retext implementation of gemojis

  • 0.5.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-22.67%
Maintainers
1
Weekly downloads
 
Created
Source

retext-emoji Build Status Coverage Status

Emoji and emoticons for retext.

Installation

npm:

$ npm install retext-emoji

Component:

$ component install wooorm/retext-emoji

Bower:

$ bower install retext-emoji

Usage & API

emoji

var Retext = require('retext');
var inspect = require('retext-inspect');
var emoji = require('retext-emoji');

var retext = new Retext().use(inspect).use(emoji, {
    'convert': 'encode'
});

retext.parse('I’m going to bed. :zzz:', function (err, tree) {
    console.log(tree.toString()); // 'I’m going to bed. 💤'

    console.log(tree.head.head);
    /**
     * SentenceNode[10]
     *   ├─ WordNode[3]
     *   │  ├─ TextNode: 'I'
     *   │  ├─ PunctuationNode: '’'
     *   │  └─ TextNode: 'm'
     *   ├─ WhiteSpaceNode: ' '
     *   ├─ WordNode[1]
     *   │  └─ TextNode: 'going'
     *   ├─ WhiteSpaceNode: ' '
     *   ├─ WordNode[1]
     *   │  └─ TextNode: 'to'
     *   ├─ WhiteSpaceNode: ' '
     *   ├─ WordNode[1]
     *   │  └─ TextNode: 'bed'
     *   ├─ PunctuationNode: '.'
     *   ├─ WhiteSpaceNode: ' '
     *   └─ EmoticonNode: '💤' [data={"names":["zzz"],"description":"sleeping symbol","tags":["sleeping"]}]
     */
});

Parameters:

  • options (Object or null)
  • options.convert ("encode" or "decode", or null):
    • When encode, converts short-codes into their unicode equivalent (e.g., :heart: and <3 to ❤️);
    • When decode, converts unicode emoji into their short-code equivalent (e.g., ❤️ and <3 to :heart:);
    • When null, applies no conversion.

EmoticonNode

All emoticons, whether emoji (❤️), emoticons (<3), or gemoji (:heart:), are classified as EmoticonNodes. EmoticonNode subclasses SymbolNode.

EmoticonNode#toEmoji()

Note that this method has no effect if you’ve specified a convert option.

var node = new TextOM.EmoticonNode(':heart:');
console.log(node); // EmoticonNode: ':heart:'

node.toEmoji();
console.log(node); // EmoticonNode: '❤️'

node.fromString('<3').toEmoji(); // EmoticonNode: '❤️'

Transforms a gemoji/emoticon into an emoji.

EmoticonNode#toGemoji()

Note that this method has no effect if you’ve specified a convert option.

var node = new TextOM.EmoticonNode('❤️');
console.log(node); // EmoticonNode: '❤️'

node.toGemoji();
console.log(node); // EmoticonNode: ':heart:'

node.fromString('<3').toGemoji();
console.log(node); // EmoticonNode: ':heart:'

Transforms an emoji/emoticon into a gemoji.

Supported Gemoji

retext-emoji supports every wooorm/gemoji and every wooorm/emoticon.

Performance

On a MacBook Air. retext works just as fast on content with emoji/gemoji/emoticons, and 2% slower on content without them, when using retext-emoji.

           retext w/o retext-emoji
  184 op/s » A paragraph (5 sentences, 100 words, 10 emojis)
  238 op/s » A paragraph (5 sentences, 100 words, no emojis)

           retext w/ retext-emoji
  183 op/s » A paragraph (5 sentences, 100 words, 10 emojis)
  232 op/s » A paragraph (5 sentences, 100 words, no emojis)

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 14 Dec 2014

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc