All Projects → deno-library → compress

deno-library / compress

Licence: MIT license
compress and uncompress for Deno

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to compress

Archiver
Easily create & extract archives, and compress & decompress files of various formats
Stars: ✭ 3,373 (+11531.03%)
Mutual labels:  gzip, zip, tar
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (+400%)
Mutual labels:  gzip, zip, tar
Sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
Stars: ✭ 1,397 (+4717.24%)
Mutual labels:  gzip, zip, tar
Swcompression
A Swift framework for working with compression, archives and containers.
Stars: ✭ 110 (+279.31%)
Mutual labels:  gzip, zip, tar
http compression
🗜️ Deno HTTP compression middleware
Stars: ✭ 34 (+17.24%)
Mutual labels:  gzip, deflate, deno
Unifiedarchive
UnifiedArchive - an archive manager with a unified way for different formats. Supports all basic (listing, reading, extracting and creation) and specific features (compression level, password-protection). Bundled with console program for working with archives.
Stars: ✭ 246 (+748.28%)
Mutual labels:  gzip, zip, tar
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+2293.1%)
Mutual labels:  gzip, zip, tar
zzlib
zlib-compressed file depacking library in Lua
Stars: ✭ 44 (+51.72%)
Mutual labels:  gzip, zip, deflate
zipstream
A command line tool that allows you to easily share files and directories over the network
Stars: ✭ 49 (+68.97%)
Mutual labels:  gzip, zip, tar
ratarmount
Random Access Read-Only Tar Mount
Stars: ✭ 217 (+648.28%)
Mutual labels:  gzip, zip, tar
Bit7z
A C++ static library offering a clean and simple interface to the 7-zip DLLs.
Stars: ✭ 159 (+448.28%)
Mutual labels:  gzip, zip, tar
Compress
Optimized Go Compression Packages
Stars: ✭ 2,478 (+8444.83%)
Mutual labels:  gzip, zip
Compressing
Everything you need for compressing and uncompressing
Stars: ✭ 268 (+824.14%)
Mutual labels:  gzip, tar
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+475.86%)
Mutual labels:  gzip, deflate
restio
HTTP Client for Dart inspired by OkHttp
Stars: ✭ 46 (+58.62%)
Mutual labels:  gzip, deflate
pyrus-cramjam
Thin Python wrapper to de/compression algorithms in Rust - lightweight & no dependencies
Stars: ✭ 40 (+37.93%)
Mutual labels:  gzip, deflate
Iostreams
IOStreams is an incredibly powerful streaming library that makes changes to file formats, compression, encryption, or storage mechanism transparent to the application.
Stars: ✭ 84 (+189.66%)
Mutual labels:  gzip, zip
Zippy
Pure Nim implementation of deflate, zlib, gzip and zip.
Stars: ✭ 88 (+203.45%)
Mutual labels:  gzip, zip
extractor
Compressed files extractor for PHP
Stars: ✭ 23 (-20.69%)
Mutual labels:  zip, tar
Datacompression
Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)
Stars: ✭ 191 (+558.62%)
Mutual labels:  gzip, zip

compress

Utilities to compress and uncompress for Deno!

  • tar
  • deflate
  • gzip
  • tgz
  • zip

Usage

If you want to read and write files, you need the following permissions:

--allow-read --allow-write

tar

For tar (un)compression, Deno v1.2.2+ is required. The reason can be seen here:

denoland/deno#6905

Definition

import { tar } from "https://deno.land/x/[email protected]/mod.ts";
// or only import tar
// import { tar } from "https://deno.land/x/[email protected]/tar/mod.ts";
export interface compressInterface {
  excludeSrc?: boolean;      // does not contain the src directory
  debug?: boolean;           // list the files and folders
}
export interface uncompressInterface {
  debug?: boolean;           // list the files and folders
}
tar.compress(src, dest, options?: compressInterface): Promise<void>;
tar.uncompress(src, dest, options?: uncompressInterface): Promise<void>;

Example

import { tar } from "https://deno.land/x/[email protected]/mod.ts";
// compress folder
await tar.compress("./test", "./test.tar");
// compress folder, exclude src directory
await tar.compress("./test", "./test.tar", { excludeSrc: true });
// compress file
await tar.compress("./test.txt", "./test.tar");
// uncompress
await tar.uncompress("./test.tar", "./dest");

deflate

This library contains a pure TypeScript implementation of deflate, and you can use deflate on its own:

import {
  deflate,
  /** Compress data using deflate, and do not append a zlib header. */
  deflateRaw,
  inflate,
  inflateRaw,
} from "https://deno.land/x/[email protected]/mod.ts";
// or only import deflate, inflate, deflateRaw, inflateRaw
// import { deflate, inflate, deflateRaw, inflateRaw } from "https://deno.land/x/[email protected]/zlib/mod.ts";
const str = "hello world!";
const bytes = new TextEncoder().encode(str);
// with zlib header
const compressed = deflate(bytes);
const decompressed = inflate(compressed);
// no zlib header
const compressed = deflateRaw(bytes);
const decompressed = inflateRaw(compressed);

gzip

Definition

interface GzipOptions {
  level: number;
  timestamp?: number;
  name?: string;
}
gzip(bytes: Uint8Array, options?:GzipOptions): Uint8Array;
gunzip(bytes: Uint8Array): Uint8Array;
gzipFile(src: string, dest: string): Promise<void>;
gunzipFile(src: string, dest: string): Promise<void>;
class GzipStream {
  compress(src: string, dest: string): Promise<void>;
  uncompress(src: string, dest: string): Promise<void>;
  on(event: "progress", listener: (percent: string) => void): this;
}

Example

Let's compress and uncompress a file. (gzip only supports compressing and decompressing a single file.)

stream mode
Useful for reading and writing large files.

import { GzipStream } from "https://deno.land/x/[email protected]/mod.ts";
// or only import GzipStream
// import { GzipStream } from "https://deno.land/x/[email protected]/gzip/mod.ts";
const gzip = new GzipStream();
gzip.on("progress", (progress: string) => {
  console.log(progress); // 0.00% => 100.00%
});
await gzip.compress("./big.mkv", "./big.mkv.gz");
await gzip.uncompress("./big.mkv.gz", "./big.mkv");

no stream mode
(This is loading all data into memory, so we can't get a progress event.)

import {
  gunzipFile,
  gzipFile,
} from "https://deno.land/x/[email protected]/mod.ts";
// or only import gzipFile, gunzipFile
// import { gzipFile, gunzipFile } from "https://deno.land/x/[email protected]/gzip/mod.ts";
await gzipFile("./deno.txt", "./deno.txt.gz");
await gunzipFile("./deno.txt.gz", "./deno.txt");

gzip a string or a byte array

This is a pure TypeScript implementation, almost as fast as a Rust implementation.

import { gunzip, gzip } from "https://deno.land/x/[email protected]/mod.ts";
// or only import gzip, gunzip
// import { gzip, gunzip } from "https://deno.land/x/[email protected]/zlib/mod.ts";
// gzip
const bytes = new TextEncoder().encode("hello");
const compressed = gzip(bytes);
// gunzip
const decompressed = gunzip(compressed);

tgz

Definition

import { tgz } from "https://deno.land/x/[email protected]/mod.ts";
// or only import tgz
// import { tgz } from "https://deno.land/x/[email protected]/tgz/mod.ts";
export interface compressInterface {
  excludeSrc?: boolean;      // does not contain the src directory
  debug?: boolean;           // list the files and folders
}
export interface uncompressInterface {
  debug?: boolean;           // list the files and folders
}
tgz.compress(src, dest, options?: compressInterface): Promise<void>;
tgz.uncompress(src, dest, options?: uncompressInterface): Promise<void>;

Example

import { tgz } from "https://deno.land/x/[email protected]/mod.ts";
// compress folder
await tgz.compress("./test", "./test.tar.gz");
// compress folder, exclude src directory
await tgz.compress("./test", "./test.tar.gz", { excludeSrc: true });
// compress file
await tgz.compress("./test.txt", "./test.tar.gz");
// uncompress
await tgz.uncompress("./test.tar.gz", "./dest");

zip

Not yet implemented

Definition

import { zip } from "https://deno.land/x/[email protected]/mod.ts";
export interface compressInterface {
  excludeSrc?: boolean;      // does not contain the src directory
  debug?: boolean;           // list the files and folders
}
export interface uncompressInterface {
  debug?: boolean;           // list the files and folders
}
zip.compress(src, dest, options?: compressInterface): Promise<void>;
zip.uncompress(src, dest, options?: uncompressInterface): Promise<void>;

test

deno test --allow-read --allow-write
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].