v3.0.4
Simple utility to compress/decompress base64 text with lz4, also parse objects
Attributes
Includes Deno configuration
Repository
Current version released
11 months ago
Dependencies
Usage Examples
This module provides functions for compressing and decompressing text and objects using the lz4 compression algorithm and base64 encoding.
compressText
This function compresses a text string using the lz4 compression algorithm and encodes it as base64.
import { compressText } from 'jsr:@lucasliet/textcompress';
const text = 'Hello, world!';
const compressedText = compressText(text);
console.log(compressedText);decompressText
This function decompresses a text string that was previously compressed and encoded in base64 using the lz4 compression algorithm.
import { decompressText } from 'jsr:@lucasliet/textcompress';
const compressedText = 'DQAAANBIZWxsbywgd29ybGQh';
const decompressedText = decompressText(compressedText);
console.log(decompressedText);compressObject
This function compresses an object by converting it to JSON, compressing the JSON string using the lz4 compression algorithm, and encoding it as base64.
import { compressObject } from 'jsr:@lucasliet/textcompress';
const obj = { ola: 'mundo' };
const compressedObj = compressObject(obj);
console.log(compressedObj);decompressObject
This function decompresses a string that was previously compressed and encoded in base64 using the lz4 compression algorithm, and parses it as JSON.
import { decompressObject } from 'jsr:@lucasliet/textcompress';
const compressedObj = 'DwAAAPAAeyJvbGEiOiJtdW5kbyJ9'; // Insert a lz4 compressed and base64-encoded string here.
const decompressedObj = decompressObject(compressedObj);
console.log(decompressedObj);Cloudflare Workers
compatible with Cloudflare Workers, using denoflare