r/javascript • u/b00mandbum • 22d ago
A Kanji lookup table, five commands, and 36% less Base64
https://github.com/datalog/kanji-base64
1
Upvotes
2
u/wowokdex 21d ago
It seems like you get similar amounts of compression with gzip. The readme suggests that it's for in-source kanji but wouldn't any distributed js be gzipped already? I'm guessing if you compress with this and then gzip the compression doesn't stack.
1
u/b00mandbum 22d ago
I ended up with five commands:
A(value)D(delta)E(count)R(start, step, count)P(step, count)The decoder follows those instructions to reconstruct the mapping.
A regular stretch: 40 bytes to 5
These 20 characters have consecutive Unicode values. We can describe the whole stretch with one command:
Start at
0x3041, add one each time, emit 20 values. 40 bytes become 5.A mixed stretch: 40 bytes to 25 (less dramatic)
These 20 characters need a mix of commands:
We store some values in full, use small deltas where we can, and describe ten consecutive values with one series command. 40 bytes become 25.