Skip to content

Commit

Permalink
feat(project): remove gzip and base64
Browse files Browse the repository at this point in the history
BREAKING CHANGE: both will increase the bundle size for the language packages
  • Loading branch information
MrWook committed Jan 2, 2025
1 parent 818dd92 commit 22710a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
16 changes: 2 additions & 14 deletions src/compress.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { compressSync, strToU8 } from 'fflate'
import { encodeBase85 } from '@alttiri/base85'

const isCompactDoubleQuotedString = (string: string) => {
// eslint-disable-next-line no-control-regex
return !string.match(/[\x00-\x1f\u2028\u2029\\"]/)
Expand Down Expand Up @@ -35,18 +32,9 @@ const compressWithPrefix = (parsed: string[]) => {
last = entry
})

return deltas
return deltas.join('')
}

export default function compress(data: string[]) {
const compressedWithPrefix = compressWithPrefix(data)
const compressedWithGzip = compressSync(
strToU8(compressedWithPrefix.join('')),
{
level: 9,
mem: 12,
},
)

return encodeBase85(compressedWithGzip)
return compressWithPrefix(data)
}
7 changes: 1 addition & 6 deletions src/decompress.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { decompressSync, strFromU8 } from 'fflate'
import { decodeBase85 } from '@alttiri/base85'

export default function decompress(encodedString: string) {
const decoded = decodeBase85(encodedString)
const decompressedBuffer = decompressSync(decoded)
const decompressedArray = strFromU8(decompressedBuffer).split(/([A-Z])/g)
const decompressedArray = encodedString.split(/([A-Z])/g)
const decompressedData = []
let last = ''
let i
Expand Down

0 comments on commit 22710a3

Please sign in to comment.