Update to fflate (#448)

* Update to fflate

* Update docs, bundler config
This commit is contained in:
101arrowz
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 79623734a1
commit 30026bb8f5
8 changed files with 14 additions and 36 deletions

View File

@@ -1,12 +0,0 @@
declare module 'pako/dist/pako_deflate' {
export const deflate: any;
}
declare module 'pako/dist/pako_inflate' {
export const inflate: any;
}
declare module 'pako' {
export const deflate: any;
export const inflate: any;
}

View File

@@ -1,4 +1,4 @@
import { deflate } from 'pako/dist/pako_deflate';
import { strFromU8, strToU8, zlibSync } from 'fflate';
import { PackFn, MARK, eventWithTimeAndPacker } from './base';
export const pack: PackFn = (event) => {
@@ -6,5 +6,5 @@ export const pack: PackFn = (event) => {
...event,
v: MARK,
};
return deflate(JSON.stringify(_e), { to: 'string' });
return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);
};

View File

@@ -1,4 +1,4 @@
import { inflate } from 'pako/dist/pako_inflate';
import { strFromU8, strToU8, unzlibSync } from 'fflate';
import { UnpackFn, eventWithTimeAndPacker, MARK } from './base';
import { eventWithTime } from '../types';
@@ -16,7 +16,7 @@ export const unpack: UnpackFn = (raw: string) => {
}
try {
const e: eventWithTimeAndPacker = JSON.parse(
inflate(raw, { to: 'string' }),
strFromU8(unzlibSync(strToU8(raw, true)))
);
if (e.v === MARK) {
return e;