Skip to content

Commit

Permalink
Revert "Merge pull request #41 from shivkanthb/unemojify"
Browse files Browse the repository at this point in the history
This reverts commit a3111c0, reversing
changes made to ada9131.
  • Loading branch information
omnidan committed Jul 7, 2017
1 parent 77e7cf7 commit 4eab337
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 51 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ node_modules
*.sublime-workspace
*.txt
test.js
coverage
coverage
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 0 additions & 28 deletions lib/emoji.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*jslint node: true*/
require('string.prototype.codepointat');
var toArray = require('lodash.toarray');

"use strict";

Expand Down Expand Up @@ -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('');
};
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
20 changes: 0 additions & 20 deletions test/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:');
})
});
});

0 comments on commit 4eab337

Please sign in to comment.