Skip to content

Supports Unemojify. #41

Merged
omnidan merged 7 commits into
omnidan:masterfrom
shivkanthb:unemojify
Jul 7, 2017
Merged

Supports Unemojify. #41
omnidan merged 7 commits into
omnidan:masterfrom
shivkanthb:unemojify

Conversation

@shivkanthb

Copy link
Copy Markdown
Contributor

Usage:

emoji.unemojify("I ❤️  ☕️! -  😯⭐️😍  ::: test : : 👍+");

Outputs:

I :heart:  :coffee:! -  :hushed::star::heart_eyes:  ::: test : : :+1:+

Fixes issue #36

@omnidan omnidan left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request! 😁 I added some comments. Please have a look at them and let me know if anything is unclear!

Comment thread .gitignore Outdated
*.txt
test.js
coverage
play.js No newline at end of file

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this added to the gitignore file? if you just used this file to test out the library, please remove it from the pull request.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed this by mistake. Will remove 👍

Comment thread lib/emoji.js Outdated
@@ -1,5 +1,6 @@
/*jslint node: true*/
require('string.prototype.codepointat');
var toArray = require('lodash/toArray');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really want to pull in all of lodash as a dependency just for a way to convert something to an array - surely there must be a way to accomplish the same behaviour without lodash?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the issue is with some complex emojis.
let's take an example.

var str = '👩‍❤️‍💋‍👩';

/* using lodash's toArray */
toArray(str);  //  outputs [ '👩‍❤️‍💋‍👩' ] (length: 1)

/* using Array.from() */
Array.from(str);  //  outputs: [ '👩', '‍', '❤', '️', '‍', '💋', '‍', '👩' ] (length : 8)

/* using string split() */
str.split('');  //  outputs [ '�', '�', '‍', '❤', '️', '‍', '�', '�', '‍', '�', '�' ] (length : 11)

I searched quite a bit to achieve this without lodash but no luck 👎 .

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivkanthb I see, in that case, it might be best to just use https://www.npmjs.com/package/lodash.toarray (so that we don't have to have all of lodash as dependency)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍

Comment thread lib/emoji.js Outdated
}

Object.prototype.getKeyByValue = function(value) {
for(var prop in this) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please stick to the style in the rest of the library (space after for and if)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Missed that. Will do! 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated :)

Comment thread test/emoji.js
it("should leave unknown emoji", function () {
var coffee = emoji.unemojify('I ⭐️ :another_one: 🥕');
should.exist(coffee);
coffee.should.be.exactly('I :star: :another_one: 🥕');

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this un-emojify the carrot emoji?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now it only unemojifies the ones present in emoji.json. If carrot is added to that, this will be resolved automatically.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, that makes sense.

@omnidan

omnidan commented Jul 4, 2017

Copy link
Copy Markdown
Owner

@shivkanthb did you manage to review the comments and push your changes yet?

@omnidan omnidan mentioned this pull request Jul 4, 2017
@omnidan

omnidan commented Jul 5, 2017

Copy link
Copy Markdown
Owner

@shivkanthb thanks! can you also document this feature in the README.md?

@shivkanthb

Copy link
Copy Markdown
Contributor Author

Readme updated 👍

@omnidan

omnidan commented Jul 7, 2017

Copy link
Copy Markdown
Owner

@shivkanthb looks good now - thank you so much 😁 👌

@omnidan omnidan merged commit a3111c0 into omnidan:master Jul 7, 2017
@omnidan

omnidan commented Jul 7, 2017

Copy link
Copy Markdown
Owner

released 1.6.0 with this PR merged

omnidan added a commit that referenced this pull request Jul 7, 2017
This reverts commit a3111c0, reversing
changes made to ada9131.
@omnidan

omnidan commented Jul 7, 2017

Copy link
Copy Markdown
Owner

@shivkanthb actually, this PR ended up breaking yarn (#45 and yarnpkg/yarn#3851), so I had to revert it. Someone came up with a possible fix in #46

timruffles added a commit to timruffles/node-emoji that referenced this pull request Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants