Compress data
parent
bbe152fa0d
commit
8cd4199555
|
@ -1,4 +1,4 @@
|
|||
node_modules/
|
||||
data/
|
||||
data/data.js
|
||||
dist/
|
||||
bundle.js
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
var buildSearch = require('../src/utils/build-search')
|
||||
var data = require('./data')
|
||||
|
||||
function uncompress (list) {
|
||||
for (var short_name in list) {
|
||||
var datum = list[short_name]
|
||||
|
||||
if (!datum.short_names) datum.short_names = []
|
||||
datum.short_names.unshift(short_name)
|
||||
|
||||
datum.sheet_x = datum.sheet[0]
|
||||
datum.sheet_y = datum.sheet[1]
|
||||
delete datum.sheet
|
||||
|
||||
if (!datum.text) datum.text = ''
|
||||
if (datum.added_in !== null && !datum.added_in) datum.added_in = '6.0'
|
||||
|
||||
datum.search = buildSearch({
|
||||
short_names: datum.short_names,
|
||||
name: datum.name,
|
||||
keywords: datum.keywords,
|
||||
emoticons: datum.emoticons
|
||||
})
|
||||
|
||||
datum.search = datum.search.join(',')
|
||||
}
|
||||
}
|
||||
|
||||
uncompress(data.emojis)
|
||||
uncompress(data.skins)
|
||||
|
||||
module.exports = data
|
|
@ -54,7 +54,7 @@
|
|||
"webpack": "1.12.14"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf data/ dist/",
|
||||
"clean": "rimraf data/data.js dist/",
|
||||
"clean:dist": "rm -rf dist/",
|
||||
"build:data": "node scripts/build-data",
|
||||
"build:example": "node scripts/build-example",
|
||||
|
@ -71,7 +71,7 @@
|
|||
"size-limit": [
|
||||
{
|
||||
"path": "dist/index.js",
|
||||
"limit": "110 KB"
|
||||
"limit": "88 KB"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ var fs = require('fs'),
|
|||
emojiData = require('emoji-datasource'),
|
||||
emojiLib = require('emojilib'),
|
||||
inflection = require('inflection'),
|
||||
mkdirp = require('mkdirp'),
|
||||
buildSearch = require('../src/utils/build-search')
|
||||
mkdirp = require('mkdirp')
|
||||
|
||||
var unifiedToNative = unified => String.fromCodePoint(
|
||||
...unified.split('-').map(s => parseInt(s, 16))
|
||||
|
@ -92,18 +91,9 @@ emojiData.forEach((datum) => {
|
|||
delete datum.texts
|
||||
|
||||
if (emojiLibMatch) {
|
||||
keywords = emojiLibMatch.keywords
|
||||
datum.keywords = emojiLibMatch.keywords
|
||||
}
|
||||
|
||||
datum.search = buildSearch({
|
||||
short_names: datum.short_names,
|
||||
name: datum.name,
|
||||
keywords,
|
||||
emoticons: datum.emoticons
|
||||
})
|
||||
|
||||
datum.search = datum.search.join(',')
|
||||
|
||||
if (datum.category == 'Skin Tones') {
|
||||
data.skins[datum.short_name] = datum
|
||||
} else {
|
||||
|
@ -117,6 +107,12 @@ emojiData.forEach((datum) => {
|
|||
data.short_names[short_name] = datum.short_name
|
||||
})
|
||||
|
||||
datum.short_names = datum.short_names.filter(i => i !== datum.short_name)
|
||||
datum.sheet = [datum.sheet_x, datum.sheet_y]
|
||||
|
||||
if (datum.text === '') delete datum.text
|
||||
if (datum.added_in === '6.0') delete datum.added_in
|
||||
|
||||
delete datum.docomo
|
||||
delete datum.au
|
||||
delete datum.softbank
|
||||
|
@ -125,6 +121,8 @@ emojiData.forEach((datum) => {
|
|||
delete datum.short_name
|
||||
delete datum.category
|
||||
delete datum.sort_order
|
||||
delete datum.sheet_x
|
||||
delete datum.sheet_y
|
||||
|
||||
for (let key in datum) {
|
||||
let value = datum[key]
|
||||
|
@ -141,8 +139,8 @@ flags.emojis.sort()
|
|||
mkdirp('data', (err) => {
|
||||
if (err) throw err
|
||||
|
||||
const stringifiedData = JSON.stringify(data).replace(/\"([A-Za-z_]+)\":/g, '$1:')
|
||||
fs.writeFile('data/index.js', `export default ${stringifiedData}`, (err) => {
|
||||
const stringified = JSON.stringify(data).replace(/\"([A-Za-z_]+)\":/g, '$1:')
|
||||
fs.writeFile('data/data.js', `module.exports = ${stringified}`, (err) => {
|
||||
if (err) throw err
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const extend = require('util')._extend
|
||||
|
||||
import data from '../../data'
|
||||
import { getData, getSanitizedData, intersect } from '.'
|
||||
|
||||
|
|
Loading…
Reference in New Issue