Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-emoji

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-emoji - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

28

lib/emoji.js
/*jslint node: true*/
require('string.prototype.codepointat');
var toArray = require('lodash.toarray');

@@ -129,1 +130,28 @@ "use strict";

}
Object.prototype.getKeyByValue = function(value) {
for (var prop in this) {
if (this.hasOwnProperty(prop)) {
if (this[prop] === value) {
return prop;
}
}
}
}
/**
* unemojify a string (replace emoji with :emoji:)
* @param {string} str
* @return {string}
*/
Emoji.unemojify = function unemojify(str) {
if (!str) return '';
var words = toArray(str);
return words.map(function(word) {
var emoji_text = Emoji.emoji.getKeyByValue(word);
if (emoji_text) {
return ':'+emoji_text+':';
}
return word;
}).join('');
};

3

package.json
{
"name": "node-emoji",
"version": "1.5.1",
"version": "1.6.0",
"description": "simple emoji support for node.js projects",

@@ -26,2 +26,3 @@ "author": "Daniel Bugl <daniel.bugl@touchlay.com>",

"dependencies": {
"lodash.toarray": "^4.4.0",
"string.prototype.codepointat": "^0.2.0"

@@ -28,0 +29,0 @@ },

# node-emoji
[![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/10](https://img.shields.io/badge/donate-paypal-yellow.svg?style=flat-square)](https://paypal.me/DanielBugl/10) [![https://gratipay.com/~omnidan/](https://img.shields.io/badge/donate-gratipay/bitcoin-yellow.svg?style=flat-square)](https://gratipay.com/~omnidan/)
[![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)
_simple emoji support for node.js projects_
![node-emoji example](http://i.imgur.com/RgFj97V.png)
![node-emoji example](https://i.imgur.com/yIo5Uux.png)

@@ -25,2 +25,3 @@ ## Installation

emoji.search('cof') // returns an array of objects with matching emoji's. `[{ emoji: '☕️', key: 'coffee' }, { emoji: ⚰', key: 'coffin'}]`
emoji.unemojify('I ❤️ 🍕') // replaces the actual emoji with :emoji:, in this case: returns "I :heart: :pizza:"
```

@@ -41,5 +42,4 @@

* 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)
* Gratipay: [![https://gratipay.com/omnidan/](https://img.shields.io/gratipay/omnidan.svg?style=flat-square)](https://gratipay.com/omnidan/)
* Bitcoin: 114veSsYoyw2QrXkPTxHD51B5i39TinsBP
* Bitcoin: [1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA](bitcoin:1J5eKsrAcPPLv5gPxSjSUkXnbJpkhndFgA)
![http://i.imgur.com/RgzXqGD.png](http://i.imgur.com/RgzXqGD.png)

@@ -113,2 +113,22 @@ /*jslint node: true*/

});
describe("unemojify(str)", function () {
it("should parse emoji and replace them with :emoji:", function() {
var coffee = emoji.unemojify('I ❤️ ☕️! - 😯⭐️😍 ::: test : : 👍+');
should.exist(coffee);
coffee.should.be.exactly('I :heart: :coffee:! - :hushed::star::heart_eyes: ::: test : : :+1:+');
})
it("should leave unknown emoji", function () {
var coffee = emoji.unemojify('I ⭐️ :another_one: 🥕');
should.exist(coffee);
coffee.should.be.exactly('I :star: :another_one: 🥕');
});
it("should parse a complex emoji like woman-kiss-woman and replace it with :woman-kiss-woman:", function() {
var coffee = emoji.unemojify('I love 👩‍❤️‍💋‍👩');
should.exist(coffee);
coffee.should.be.exactly('I love :woman-kiss-woman:');
})
});
});

Sorry, the diff of this file is not supported yet

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