-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from serebrov/107-vite-import-error
[#107] Extract compress method (used by build script)
- Loading branch information
Showing
3 changed files
with
52 additions
and
35 deletions.
There are no files selected for viewing
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