-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
54 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const mapping = { | ||
name: 'a', | ||
unified: 'b', | ||
non_qualified: 'c', | ||
has_img_apple: 'd', | ||
has_img_google: 'e', | ||
has_img_twitter: 'f', | ||
has_img_facebook: 'h', | ||
keywords: 'j', | ||
sheet: 'k', | ||
emoticons: 'l', | ||
text: 'm', | ||
short_names: 'n', | ||
added_in: 'o', | ||
} | ||
|
||
const compress = (emoji) => { | ||
emoji.short_names = emoji.short_names.filter((short_name) => { | ||
return short_name !== emoji.short_name | ||
}) | ||
delete emoji.short_name | ||
|
||
emoji.sheet = [emoji.sheet_x, emoji.sheet_y] | ||
delete emoji.sheet_x | ||
delete emoji.sheet_y | ||
|
||
emoji.added_in = parseInt(emoji.added_in) | ||
if (emoji.added_in === 6) { | ||
delete emoji.added_in | ||
} | ||
|
||
for (let key in mapping) { | ||
emoji[mapping[key]] = emoji[key] | ||
delete emoji[key] | ||
} | ||
|
||
for (let key in emoji) { | ||
let value = emoji[key] | ||
|
||
if (Array.isArray(value) && !value.length) { | ||
delete emoji[key] | ||
} else if (typeof value === 'string' && !value.length) { | ||
delete emoji[key] | ||
} else if (value === null) { | ||
delete emoji[key] | ||
} | ||
} | ||
} | ||
|
||
module.exports = { compress } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters