@robinpath/zip
0.1.3Node.jsPublicCompression utilities: gzip, deflate, Brotli for strings and files
Zip
Compression utilities: gzip, deflate, Brotli for strings and files
Package: @robinpath/zip | Category: Other | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the zip module when you need to:
- Compress a string with gzip, return base64 -- Use
zip.gzipto perform this operation - Decompress a gzip base64 string to text -- Use
zip.gunzipto perform this operation - Compress a string with deflate, return base64 -- Use
zip.deflateto perform this operation - Decompress deflate base64 data to text -- Use
zip.inflateto perform this operation - Compress a file with gzip -- Use
zip.gzipFileto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
gzip | Compress a string with gzip, return base64 | Base64-encoded gzip data |
gunzip | Decompress a gzip base64 string to text | Decompressed string |
deflate | Compress a string with deflate, return base64 | Base64-encoded deflate data |
inflate | Decompress deflate base64 data to text | Decompressed string |
gzipFile | Compress a file with gzip | Output file path |
gunzipFile | Decompress a .gz file | Output file path |
brotliCompress | Compress a string with Brotli, return base64 | Base64-encoded Brotli data |
brotliDecompress | Decompress Brotli base64 data to text | Decompressed string |
isGzipped | Check if a base64 string is gzip-compressed | True if gzipped |
Functions
gzip
Compress a string with gzip, return base64
Module: zip | Returns: string -- Base64-encoded gzip data
zip.gzip "hello world"
| Parameter | Type | Required | Description |
|---|---|---|---|
str | string | Yes | String to compress |
gunzip
Decompress a gzip base64 string to text
Module: zip | Returns: string -- Decompressed string
zip.gunzip $compressed
| Parameter | Type | Required | Description |
|---|---|---|---|
base64 | string | Yes | Base64 gzip data |
deflate
Compress a string with deflate, return base64
Module: zip | Returns: string -- Base64-encoded deflate data
zip.deflate "hello"
| Parameter | Type | Required | Description |
|---|---|---|---|
str | string | Yes | String to compress |
inflate
Decompress deflate base64 data to text
Module: zip | Returns: string -- Decompressed string
zip.inflate $compressed
| Parameter | Type | Required | Description |
|---|---|---|---|
base64 | string | Yes | Base64 deflate data |
gzipFile
Compress a file with gzip
Module: zip | Returns: string -- Output file path
zip.gzipFile "data.txt"
| Parameter | Type | Required | Description |
|---|---|---|---|
inputPath | string | Yes | Path to input file |
outputPath | string | No | Path for output .gz file |
gunzipFile
Decompress a .gz file
Module: zip | Returns: string -- Output file path
zip.gunzipFile "data.txt.gz"
| Parameter | Type | Required | Description |
|---|---|---|---|
inputPath | string | Yes | Path to .gz file |
outputPath | string | No | Path for output file |
brotliCompress
Compress a string with Brotli, return base64
Module: zip | Returns: string -- Base64-encoded Brotli data
zip.brotliCompress "hello"
| Parameter | Type | Required | Description |
|---|---|---|---|
str | string | Yes | String to compress |
brotliDecompress
Decompress Brotli base64 data to text
Module: zip | Returns: string -- Decompressed string
zip.brotliDecompress $compressed
| Parameter | Type | Required | Description |
|---|---|---|---|
base64 | string | Yes | Base64 Brotli data |
isGzipped
Check if a base64 string is gzip-compressed
Module: zip | Returns: boolean -- True if gzipped
zip.isGzipped $data
| Parameter | Type | Required | Description |
|---|---|---|---|
base64 | string | Yes | Base64 string to check |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "Gzip and validate result"
do
set $result as zip.gzip "hello world"
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. Multi-step Zip workflow
Chain multiple zip operations together.
@desc "Gzip, gunzip, and more"
do
set $r_gzip as zip.gzip "hello world"
set $r_gunzip as zip.gunzip $compressed
set $r_deflate as zip.deflate "hello"
print "All operations complete"
enddo
2. Safe gzip with validation
Check results before proceeding.
@desc "Gzip and validate result"
do
set $result as zip.gzip "hello world"
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (3)
| Version | Tag | Published |
|---|---|---|
| 0.1.3 | latest | 21 days ago |
| 0.1.2 | 21 days ago | |
| 0.1.1 | 1 months ago |
Related Modules
@robinpathv0.1.4
SMTP email sending and address parsing for RobinPath
hash
JS@robinpathv0.1.3
Cryptographic hashing utilities: MD5, SHA family, HMAC, CRC32, file hashing, UUID v5 generation, secure random bytes, and content fingerprinting
csv
JS@robinpathv0.1.2
Parse and stringify CSV data
apollo
JS@robinpathv0.1.2
Apollo module for RobinPath.
$ robinpath add @robinpath/zip
