🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@witzbould/utils-string-compression

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@witzbould/utils-string-compression

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

latest
Source
npmnpm
Version
2.4.0
Version published
Weekly downloads
26
333.33%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

utils

FAQs

Package last updated on 20 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts