@witzbould/utils-string-compression

2.3.0 • Public • Published

String Compression

Compress or decompress a string with native browser APIs with 'gzip', 'deflate', or 'deflate-raw'.
Compatible to use with atob and btoa.

Example Usage

import { compress, decompress } from '@witzbould/utils-string-compression';

const input = '{"id":1,"todo":"Do something nice for someone you care about","completed":true,"userId":26}';

const compressedString = await compress(input, 'gzip');
const urlFriendly = encodeURIComponent(btoa(compressedString));

const binaryString = atob(decodeURIComponent(urlFriendly));
const output = await decompress(binaryString, 'gzip');

console.assert(input === output);

Package Sidebar

Install

npm i @witzbould/utils-string-compression

Weekly Downloads

0

Version

2.3.0

License

ISC

Unpacked Size

3.11 kB

Total Files

4

Last publish

Collaborators

  • witzbould