Skip to content

Commit c48df44

Browse files
committed
Add g-zip size
1 parent 47b03bd commit c48df44

File tree

7 files changed

+47
-17
lines changed

7 files changed

+47
-17
lines changed

package-lock.json

+21-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"eslint-plugin-storybook": "^0.11.1",
8585
"file-loader": "^6.2.0",
8686
"globals": "^15.12.0",
87+
"gzip-size": "^7.0.0",
8788
"html-webpack-plugin": "^5.6.3",
8889
"jest": "^29.7.0",
8990
"jsdom": "^25.0.1",

src/services/dictionary.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IAlphabets } from 'reducers'
44

55
import {
66
convertCases,
7+
deduplicate,
78
filterLatin,
89
filterNiqqud,
910
getCaseTips,
@@ -235,20 +236,22 @@ class DictionaryClass {
235236

236237
switch (lang) {
237238
case 'isv':
238-
splittedField = this
239-
.splittedMap['isv-src']
240-
.get(id)
241-
.map((word) => this.searchPrepare(lang, word))
242-
.filter((item, i, ar) => ar.indexOf(item) === i)
243-
239+
splittedField = deduplicate(
240+
this
241+
.splittedMap['isv-src']
242+
.get(id)
243+
.map((word) => this.searchPrepare(lang, word))
244+
)
245+
244246
break
245247
case 'isv-src':
246-
splittedField = this
247-
.splitWords(fromField)
248-
.concat(getWordForms(item))
249-
.map((word) => this.searchPrepare('isv-src', getLatin(word, '2')))
250-
.filter((item, i, ar) => ar.indexOf(item) === i)
251-
248+
splittedField = deduplicate(
249+
this
250+
.splitWords(fromField)
251+
.concat(getWordForms(item))
252+
.map((word) => this.searchPrepare('isv-src', getLatin(word, '2')))
253+
)
254+
252255
break
253256
default:
254257
splittedField = this.splitWords(fromField).map((word) => this.searchPrepare(lang, word))

src/services/generateDictionary.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { Dictionary, loadTablesData } from 'services'
66

77
import { getColumnName, transposeMatrix } from 'utils'
88

9+
import { gzipSizeSync } from 'gzip-size'
10+
911

1012
loadTablesData.then(({ data, columns }) => {
1113
Dictionary.init(data)
@@ -24,7 +26,7 @@ loadTablesData.then(({ data, columns }) => {
2426
}
2527
})
2628

27-
const basicData = transposeMatrix(basicDataTransposed)
29+
const basicData = transposeMatrix<string>(basicDataTransposed)//.sort((a, b) => a[1].localeCompare(b[1]))
2830

2931
const searchIndexBasic = [
3032
'isv-src',
@@ -49,6 +51,10 @@ loadTablesData.then(({ data, columns }) => {
4951
fs.writeFileSync('./static/data/basic.json', jsonDataStr)
5052
fs.writeFileSync('./static/data/translateStatistic.json', translateStatisticStr)
5153

54+
const sizeMB = gzipSizeSync(jsonDataStr) / 1000000
55+
// eslint-disable-next-line no-console
56+
console.info(`basic.json g-zip size: ${sizeMB.toFixed(2)} MB`)
57+
5258
addLangs.forEach((lang) => {
5359
const langDataTransposed = [
5460
columns.find(([fieldName]) => fieldName === lang),

src/utils/deduplicate/deduplicate.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const deduplicate = (arr) => Array.from(new Set(arr))

src/utils/deduplicate/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './deduplicate'

src/utils/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from './bcp47'
22
export * from './convertCases'
33
export * from './createTaggedTemplate'
4+
export * from './deduplicate'
45
export * from './filterLatin'
56
export * from './filterNiqqud'
67
export * from './getAllDataFromResults'

0 commit comments

Comments
 (0)