Skip to content

Commit 0a21b58

Browse files
committed
test: report minified size in dump.js
1 parent 7acec25 commit 0a21b58

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • tests/encoding/fixtures/multi-byte

tests/encoding/fixtures/multi-byte/dump.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { gzipSync } from 'node:zlib'
77

88
// const splitChunks = new Set(['jis0208', 'jis0212', 'big5']) // pretty-print into chunks, non-continious anyway
99

10+
// references must start with `$` so that parser know which ones to expand
1011
const reusable = Object.entries({
1112
$C: ['АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'], // [[1040, 6], "Ё", [1046, 26]],
1213
$c: ['абвгдеёжзийклмнопрстуфхцчшщъыьэюя'], // [[1072, 6], "ё", [1078, 26]],
@@ -128,7 +129,7 @@ function encodeString(s, lastconseq) {
128129
return str.length * 1.5 < partsstr.length && str.length < partsstr.length - 3 ? [str] : parts
129130
}
130131

131-
let final = '{\n'
132+
let final = ''
132133
for (const [encoding, chars] of Object.entries(encodings)) {
133134
const list = []
134135
let str = chars
@@ -224,13 +225,15 @@ for (const [encoding, chars] of Object.entries(encodings)) {
224225
if (tmp.length > 0) list2.push(tmp)
225226

226227
const dump = list2.join(',\n ')
227-
final += ` ${JSON.stringify(encoding)}: [\n ${dump}\n ],\n`
228+
final += final ? ',\n' : '{\n'
229+
final += ` ${JSON.stringify(encoding)}: [\n ${dump}\n ]\n`
228230
}
229231

230232
final += '}'
231233

232234
// console.error([...stats].sort((a, b) => b[1] - a[1]))
233235

234236
console.log(final)
235-
console.error(`Raw size: ${final.length}`)
236-
console.error(`Gzip size: ${gzipSync(final).length}`)
237+
const json = JSON.stringify(JSON.parse(final)) // report minified size
238+
console.error(`Raw size: ${json.length}`)
239+
console.error(`Gzip size: ${gzipSync(json).length}`)

0 commit comments

Comments
 (0)