Skip to content

Commit

Permalink
add new hardcoded words
Browse files Browse the repository at this point in the history
  • Loading branch information
notwaldorf committed Jun 10, 2017
1 parent 53e7bb6 commit e6764c4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ console.log(translate.translate("the house is on fire and the cat is eating the

The `emoji-translate` api has 5 methods:

module.exports.isMaybeAlreadyAnEmoji = isMaybeAlreadyAnEmoji;
module.exports.getAllEmojiForWord = getAllEmojiForWord;
module.exports.getEmojiForWord = getEmojiForWord;
module.exports.translateForDisplay = translateForDisplay;
module.exports.translate = translate;
* `isMaybeAlreadyAnEmoji` -- returns true if a character is very likely already an emoji (i.e. it exists as a key in `emojilib`)
* `isMaybeAlreadyAnEmoji` -- returns true if a character is already an emoji
* `getAllEmojiForWord(word)` -- returns a list of possible emoji translations
* `getEmojiForWord(word)` -- returns a random translation from the list
returned by `getAllEmojiForWord(word)`
Expand Down
14 changes: 14 additions & 0 deletions emoji-translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ function getAllEmojiForWord(originalWord) {
return useful;
}

// If it's "i" or "i", add some faces to it.
if (word === 'i' || word === 'you') {
useful.push('😀');
useful.push('😊');
} else if (word === 'she'){
useful.push('💁');
} else if (word === 'he'){
useful.push('💁‍♂️');
} else if (word === 'we' || word === 'they') {
useful.push('👩‍👩‍👦‍👦');
} else if (word === 'am' || word === 'is' || word === 'are') {
useful.push('👉');
}

for (let emoji in allEmoji) {
let words = allEmoji[emoji].keywords;
if (word == allEmoji[emoji].char ||
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moji-translate",
"version": "1.0.2",
"version": "1.0.3",
"description": "A library that translates english words to emoji",
"main": "emoji-translate.js",
"scripts": {
Expand Down
9 changes: 6 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ test('annoying translations', function(t) {
// these should not be flags.
t.equal('im', translate.translate('im').trim());
t.equal('in', translate.translate('in').trim());
t.equal('is', translate.translate('is').trim());
t.equal('am', translate.translate('am').trim());

// t.equal('is', translate.translate('is').trim());
// t.equal('am', translate.translate('am').trim());

// hi should work
t.notEqual('hi', translate.translate('hi').trim());
t.equal('👋', translate.translate('hi'));
t.notEqual('i am', translate.translate('i am').trim());
t.notEqual('she he is', translate.translate('she he is').trim());
t.notEqual('we they are', translate.translate('we they are').trim());
t.end();
});

0 comments on commit e6764c4

Please sign in to comment.