Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

targz

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

targz

TarGz for NodeJS

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65K
increased by11.71%
Maintainers
1
Weekly downloads
 
Created
Source

TarGz for NodeJS

Simple tar.gz compression and decompression for NodeJS.

Installation

npm install targz

Simple Usage


var targz = require('targz');

// compress files into tar.gz archive
targz.compress({
    src: 'path_to_files',
    dest: 'path_to_compressed_file'
}, function(err){
    if(err) {
        console.log(err);
    } else {
        console.log("Done!");
    }
});

// decompress files from tar.gz archive
targz.decompress({
    src: 'path_to_compressed file',
    dest: 'path_to_extract'
}, function(err){
    if(err) {
        console.log(err);
    } else {
        console.log("Done!");
    }
});

Advanced Usage

You can adjust tar and gzip/gunzip parameters by using optional parameters. The API:


// Compress API
targz.compress( options, callback );

// Decompress API
targz.decompress( options, callback );

Where supported options are:

  • src - (String) The path to files to be compressed
  • dest - (String) The path to tar.gz file to be created
  • tar - (Object) Adjust tar options. See tar-fs docs for details. OPTIONAL.
    • ignore - (Function) Ignore/filter files
    • entries - (Array) Define list of files
    • map - (Function) Modify the headers
    • mapStream - (Function) Modify the input/output file streams
    • dmode - (Number) Set the permissions for directories
    • fmode - (Number) Set permissions for files
    • strict - (Boolean) Ignore errors due to unsupported entry types (like device files). Default: true
    • dereference - (Boolean) Pack the contents of the symlink instead of the link itself. Default: false
  • gz - (Object) Adjust gzip/gunzip options. See zlib docs for details. OPTIONAL.

Example


var targz = require('targz');

// compress files into tar.gz archive while filtering all .bin files and having gzip level/memLevel set to 6
targz.compress({
    src: 'path_to_files',
    dest: 'path_to_compressed_file',
    tar: {
        ignore: function(name) {
            return path.extname(name) === '.bin' // ignore .bin files when packing
        }
    },
    gz: {
        level: 6;
        memLevel: 6;
    }
}, function(err){
    if(err) {
        console.log(err);
    } else {
        console.log("Done!");
    }
});

License

MIT

Keywords

FAQs

Package last updated on 02 Aug 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc