Skip to content

Commit

Permalink
Merge branch 'master' into build
Browse files Browse the repository at this point in the history
  • Loading branch information
serebrov committed Mar 20, 2021
2 parents 6995c17 + e9a2486 commit e4c691d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "emoji-mart-vue-fast",
"version": "9.1.0",
"version": "9.1.2",
"description": "Customizable Slack-like emoji picker for VueJS, fast version",
"main": "dist/emoji-mart.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var fs = require('fs'),
emojiLib = require('emojilib'),
inflection = require('inflection')

var { compress } = require('../src/utils/data')
var { compress } = require('./compress')

var categories = [
['Smileys & Emotion', 'smileys'],
Expand Down
50 changes: 50 additions & 0 deletions scripts/compress.js
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 }
35 changes: 1 addition & 34 deletions src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,6 @@ const buildSearch = (emoji) => {
return search.join(',')
}

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]
}
}
}

function deepFreeze(object) {
// Retrieve the property names defined on object
var propNames = Object.getOwnPropertyNames(object)
Expand Down Expand Up @@ -119,4 +86,4 @@ const uncompress = (data) => {
return data
}

module.exports = { buildSearch, compress, uncompress }
export { buildSearch, uncompress }

0 comments on commit e4c691d

Please sign in to comment.