Update to fflate (#448)

* Update to fflate

* Update docs, bundler config
This commit is contained in:
101arrowz
2020-12-22 04:40:37 -08:00
committed by GitHub
parent 05f4cea377
commit e946b69d3f
8 changed files with 14 additions and 36 deletions

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;