All files / util/src/compression gzip.ts

100% Statements 10/10
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 141x 1x   1x     2x   1x 1x   1x 1x  
import {fromStream} from '../streams/fromStream';
import {toStream} from '../streams/toStream';
 
const pipeThrough = async (
  data: Uint8Array,
  transform: ReadableWritablePair<Uint8Array, Uint8Array>,
): Promise<Uint8Array> => await fromStream(toStream(data).pipeThrough<Uint8Array>(transform));
 
export const gzip = async (data: Uint8Array): Promise<Uint8Array> =>
  await pipeThrough(data, new CompressionStream('gzip') as any);
 
export const ungzip = async (data: Uint8Array): Promise<Uint8Array> =>
  await pipeThrough(data, new DecompressionStream('gzip') as any);