Skip to content

Latest commit

 

History

History
40 lines (27 loc) · 720 Bytes

README.md

File metadata and controls

40 lines (27 loc) · 720 Bytes

Smaller than base64, only use ASCII, can run in web browser.

The project was born for vite-plugin-singlefile-compression.

Setup

npm i base128-ascii
import base128 from "base128-ascii"
import fs from 'fs'

const encodedTemplate = base128.encode(Uint8Array.from(fs.readFileSync("example.gz"))).toJSTemplateLiterals()

const decoded = base128.decode(eval(encodedTemplate))

Effect

Encode this jpg file, use base128 is 109.85 KiB smaller than base64:

screenshot-45.519.jpg
file length: 682086

encode:
bytes length: 796961
eval length: 779527
decoded length: 682086
equal: true

base64:
length: 909448