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

tar

Package Overview
Dependencies
Maintainers
4
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tar

tar for node

  • 3.1.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.6M
decreased by-68.16%
Maintainers
4
Weekly downloads
 
Created

What is tar?

The tar npm package is used for manipulating tarballs, which are archives of files and directories. It allows users to create new tarballs, extract files from existing tarballs, and list or update the contents of tarballs. It is a JavaScript implementation of the POSIX tar command and is commonly used in Node.js applications for handling tar files.

What are tar's main functionalities?

Creating a tarball

This feature allows you to create a tarball. The example code demonstrates how to create a gzipped tarball named 'my-tarball.tgz' that contains 'file1.js' and 'file2.txt'.

const tar = require('tar');
tar.c(
  {
    gzip: true,
    file: 'my-tarball.tgz'
  },
  ['file1.js', 'file2.txt']
).then(_ => console.log('Tarball has been created.'));

Extracting a tarball

This feature allows you to extract files from a tarball. The example code demonstrates how to extract 'my-tarball.tgz' into the directory 'some/dir'.

const tar = require('tar');
tar.x(
  {
    file: 'my-tarball.tgz',
    C: 'some/dir'
  }
).then(_ => console.log('Tarball has been extracted.'));

Listing contents of a tarball

This feature allows you to list the contents of a tarball. The example code demonstrates how to list the paths of all files and directories in 'my-tarball.tgz'.

const tar = require('tar');
tar.t(
  {
    file: 'my-tarball.tgz',
    onentry: entry => console.log(entry.path)
  }
).then(_ => console.log('Contents have been listed.'));

Updating a tarball

This feature allows you to update a tarball by adding new files. The example code demonstrates how to add 'newfile.txt' to the existing 'my-tarball.tgz'.

const tar = require('tar');
tar.u(
  {
    file: 'my-tarball.tgz'
  },
  ['newfile.txt']
).then(_ => console.log('Tarball has been updated.'));

Other packages similar to tar

FAQs

Package last updated on 02 Aug 2017

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