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.6.0 to 1.6.1

28

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

@@ -130,28 +129,1 @@ "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.6.0",
"version": "1.6.1",
"description": "simple emoji support for node.js projects",

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

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

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

@@ -25,3 +25,2 @@ # node-emoji

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:"
```

@@ -28,0 +27,0 @@

@@ -113,22 +113,2 @@ /*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