JSPM

@witzbould/utils-string-compression

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 46
  • Score
    100M100P100Q55701F
  • License ISC

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

Package Exports

  • @witzbould/utils-string-compression
  • @witzbould/utils-string-compression/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@witzbould/utils-string-compression) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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);