node-emoji
Advanced tools
Comparing version 1.6.0 to 1.6.1
/*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(''); | ||
}; |
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
147195
1545
43
- Removedlodash.toarray@^4.4.0
- Removedlodash.toarray@4.4.0(transitive)