From 4eab3374be3ab268f496dcde437d59c44a1a05fb Mon Sep 17 00:00:00 2001 From: Daniel Bugl Date: Fri, 7 Jul 2017 10:38:13 -0400 Subject: [PATCH] Revert "Merge pull request #41 from shivkanthb/unemojify" This reverts commit a3111c00a0eef75436caa49ffc899733e9b2913f, reversing changes made to ada91319728df75dff4ba7fbbfc2fd77b8fc2cdb. --- .gitignore | 2 +- README.md | 1 - lib/emoji.js | 28 ---------------------------- package.json | 1 - test/emoji.js | 20 -------------------- 5 files changed, 1 insertion(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 335e141..8262c2d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ node_modules *.sublime-workspace *.txt test.js -coverage \ No newline at end of file +coverage diff --git a/README.md b/README.md index fc1adbd..53aa787 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ emoji.get(':fast_forward:') // `.get` also supports github flavored markdown emo emoji.emojify('I :heart: :coffee:!') // replaces all :emoji: with the actual emoji, in this case: returns "I ❤️ ☕️!" emoji.random() // returns a random emoji + key, e.g. `{ emoji: '❤️', key: 'heart' }` 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:" ``` ## Adding new emoji diff --git a/lib/emoji.js b/lib/emoji.js index 1046eea..8141f07 100644 --- a/lib/emoji.js +++ b/lib/emoji.js @@ -1,6 +1,5 @@ /*jslint node: true*/ require('string.prototype.codepointat'); -var toArray = require('lodash.toarray'); "use strict"; @@ -127,30 +126,3 @@ Emoji.search = function search(str) { }; }); } - -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(''); -}; diff --git a/package.json b/package.json index 7162b49..3c11832 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "url": "https://github.com/omnidan/node-emoji/issues" }, "dependencies": { - "lodash.toarray": "^4.4.0", "string.prototype.codepointat": "^0.2.0" }, "devDependencies": { diff --git a/test/emoji.js b/test/emoji.js index 4210dba..a77687a 100644 --- a/test/emoji.js +++ b/test/emoji.js @@ -110,24 +110,4 @@ describe("emoji.js", function () { matchingEmojis.length.should.be.exactly(0); }); }); - - 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:'); - }) - }); });