Skip to content

Commit 4eab337

Browse files
committed
Revert "Merge pull request #41 from shivkanthb/unemojify"
This reverts commit a3111c0, reversing changes made to ada9131.
1 parent 77e7cf7 commit 4eab337

File tree

5 files changed

+1
-51
lines changed

5 files changed

+1
-51
lines changed

β€Ž.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ node_modules
44
*.sublime-workspace
55
*.txt
66
test.js
7-
coverage
7+
coverage

β€ŽREADME.md

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ emoji.get(':fast_forward:') // `.get` also supports github flavored markdown emo
2222
emoji.emojify('I :heart: :coffee:!') // replaces all :emoji: with the actual emoji, in this case: returns "I ❀️ β˜•οΈ!"
2323
emoji.random() // returns a random emoji + key, e.g. `{ emoji: '❀️', key: 'heart' }`
2424
emoji.search('cof') // returns an array of objects with matching emoji's. `[{ emoji: 'β˜•οΈ', key: 'coffee' }, { emoji: ⚰', key: 'coffin'}]`
25-
emoji.unemojify('I ❀️ πŸ•') // replaces the actual emoji with :emoji:, in this case: returns "I :heart: :pizza:"
2625
```
2726

2827
## Adding new emoji

β€Žlib/emoji.js

-28
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*jslint node: true*/
22
require('string.prototype.codepointat');
3-
var toArray = require('lodash.toarray');
43

54
"use strict";
65

@@ -127,30 +126,3 @@ Emoji.search = function search(str) {
127126
};
128127
});
129128
}
130-
131-
Object.prototype.getKeyByValue = function(value) {
132-
for (var prop in this) {
133-
if (this.hasOwnProperty(prop)) {
134-
if (this[prop] === value) {
135-
return prop;
136-
}
137-
}
138-
}
139-
}
140-
141-
/**
142-
* unemojify a string (replace emoji with :emoji:)
143-
* @param {string} str
144-
* @return {string}
145-
*/
146-
Emoji.unemojify = function unemojify(str) {
147-
if (!str) return '';
148-
var words = toArray(str);
149-
return words.map(function(word) {
150-
var emoji_text = Emoji.emoji.getKeyByValue(word);
151-
if (emoji_text) {
152-
return ':'+emoji_text+':';
153-
}
154-
return word;
155-
}).join('');
156-
};

β€Žpackage.json

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"url": "https://github.com/omnidan/node-emoji/issues"
2424
},
2525
"dependencies": {
26-
"lodash.toarray": "^4.4.0",
2726
"string.prototype.codepointat": "^0.2.0"
2827
},
2928
"devDependencies": {

β€Žtest/emoji.js

-20
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,4 @@ describe("emoji.js", function () {
110110
matchingEmojis.length.should.be.exactly(0);
111111
});
112112
});
113-
114-
describe("unemojify(str)", function () {
115-
it("should parse emoji and replace them with :emoji:", function() {
116-
var coffee = emoji.unemojify('I ❀️ β˜•οΈ! - 😯⭐️😍 ::: test : : πŸ‘+');
117-
should.exist(coffee);
118-
coffee.should.be.exactly('I :heart: :coffee:! - :hushed::star::heart_eyes: ::: test : : :+1:+');
119-
})
120-
121-
it("should leave unknown emoji", function () {
122-
var coffee = emoji.unemojify('I ⭐️ :another_one: πŸ₯•');
123-
should.exist(coffee);
124-
coffee.should.be.exactly('I :star: :another_one: πŸ₯•');
125-
});
126-
127-
it("should parse a complex emoji like woman-kiss-woman and replace it with :woman-kiss-woman:", function() {
128-
var coffee = emoji.unemojify('I love πŸ‘©β€β€οΈβ€πŸ’‹β€πŸ‘©');
129-
should.exist(coffee);
130-
coffee.should.be.exactly('I love :woman-kiss-woman:');
131-
})
132-
});
133113
});

0 commit comments

Comments
Β (0)