Modules@robinpath/zip
zip

@robinpath/zip

0.1.3Node.jsPublic

Compression 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.gzip to perform this operation
  • Decompress a gzip base64 string to text -- Use zip.gunzip to perform this operation
  • Compress a string with deflate, return base64 -- Use zip.deflate to perform this operation
  • Decompress deflate base64 data to text -- Use zip.inflate to perform this operation
  • Compress a file with gzip -- Use zip.gzipFile to perform this operation

Quick Reference

FunctionDescriptionReturns
gzipCompress a string with gzip, return base64Base64-encoded gzip data
gunzipDecompress a gzip base64 string to textDecompressed string
deflateCompress a string with deflate, return base64Base64-encoded deflate data
inflateDecompress deflate base64 data to textDecompressed string
gzipFileCompress a file with gzipOutput file path
gunzipFileDecompress a .gz fileOutput file path
brotliCompressCompress a string with Brotli, return base64Base64-encoded Brotli data
brotliDecompressDecompress Brotli base64 data to textDecompressed string
isGzippedCheck if a base64 string is gzip-compressedTrue if gzipped

Functions

gzip

Compress a string with gzip, return base64

Module: zip | Returns: string -- Base64-encoded gzip data

zip.gzip "hello world"
ParameterTypeRequiredDescription
strstringYesString to compress

gunzip

Decompress a gzip base64 string to text

Module: zip | Returns: string -- Decompressed string

zip.gunzip $compressed
ParameterTypeRequiredDescription
base64stringYesBase64 gzip data

deflate

Compress a string with deflate, return base64

Module: zip | Returns: string -- Base64-encoded deflate data

zip.deflate "hello"
ParameterTypeRequiredDescription
strstringYesString to compress

inflate

Decompress deflate base64 data to text

Module: zip | Returns: string -- Decompressed string

zip.inflate $compressed
ParameterTypeRequiredDescription
base64stringYesBase64 deflate data

gzipFile

Compress a file with gzip

Module: zip | Returns: string -- Output file path

zip.gzipFile "data.txt"
ParameterTypeRequiredDescription
inputPathstringYesPath to input file
outputPathstringNoPath for output .gz file

gunzipFile

Decompress a .gz file

Module: zip | Returns: string -- Output file path

zip.gunzipFile "data.txt.gz"
ParameterTypeRequiredDescription
inputPathstringYesPath to .gz file
outputPathstringNoPath for output file

brotliCompress

Compress a string with Brotli, return base64

Module: zip | Returns: string -- Base64-encoded Brotli data

zip.brotliCompress "hello"
ParameterTypeRequiredDescription
strstringYesString to compress

brotliDecompress

Decompress Brotli base64 data to text

Module: zip | Returns: string -- Decompressed string

zip.brotliDecompress $compressed
ParameterTypeRequiredDescription
base64stringYesBase64 Brotli data

isGzipped

Check if a base64 string is gzip-compressed

Module: zip | Returns: boolean -- True if gzipped

zip.isGzipped $data
ParameterTypeRequiredDescription
base64stringYesBase64 string to check

Error Handling

All functions throw on failure. Common errors:

ErrorCause
(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)

VersionTagPublished
0.1.3latest21 days ago
0.1.221 days ago
0.1.11 months ago
Install
$ robinpath add @robinpath/zip

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.3
LicenseMIT
Unpacked Size5.7 KB
Versions3
Weekly Downloads21
Total Downloads21
Stars0
Last Publish21 days ago
Created1 months ago

Keywords

Category

utilities