DefinitelyTyped/types/node-gzip/node-gzip-tests.ts
2019-07-01 11:14:45 -07:00

17 lines
470 B
TypeScript

import { gzip, ungzip } from 'node-gzip';
const testGzip = async () => {
const someBuffer = Buffer.from('hello');
const zipped1 = await gzip(someBuffer);
const zipped2 = await gzip('gzipping a string directly');
return [zipped1.byteLength, zipped2[0]];
};
const testUngzip = async () => {
const data = Buffer.from('H4sICHeEGV0AA2EA4wIAkwbXMgEAAAA=', 'base64');
const ungzipped = await ungzip(data);
return ungzipped.toString('utf-8');
};