Socket
Socket
Sign inDemoInstall

tar

Package Overview
Dependencies
18
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tar

tar for node


Version published
Weekly downloads
21M
decreased by-20.42%
Maintainers
1
Install size
643 kB
Created
Weekly downloads
 

Package description

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

Readme

Source

node-tar

Tar for Node.js.

Goals of this project

  1. Be able to parse and reasonably extract the contents of any tar file created by any program that creates tar files, period.

    At least, this includes every version of:

    • bsdtar
    • gnutar
    • solaris posix tar
    • Joerg Schilling's star ("Schilly tar")
  2. Create tar files that can be extracted by any of the following tar programs:

    • bsdtar/libarchive version 2.6.2
    • gnutar 1.15 and above
    • SunOS Posix tar
    • Joerg Schilling's star ("Schilly tar")
  3. 100% test coverage. Speed is important. Correctness is slightly more important.

  4. Create the kind of tar interface that Node users would want to use.

  5. Satisfy npm's needs for a portable tar implementation with a JavaScript interface.

  6. No excuses. No complaining. No tolerance for failure.

But isn't there already a tar.js?

Yes, there are a few. This one is going to be better, and it will be fanatically maintained, because npm will depend on it.

That's why I need to write it from scratch. Creating and extracting tarballs is such a large part of what npm does, I simply can't have it be a black box any longer.

Didn't you have something already? Where'd it go?

It's in the "old" folder. It's not functional. Don't use it.

It was a useful exploration to learn the issues involved, but like most software of any reasonable complexity, node-tar won't be useful until it's been written at least 3 times.

FAQs

Last updated on 20 Nov 2011

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc