Socket
Socket
Sign inDemoInstall

@types/tar-stream

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/tar-stream

TypeScript definitions for tar-stream


Version published
Maintainers
1
Created

What is @types/tar-stream?

@types/tar-stream provides TypeScript type definitions for the tar-stream package, which is a streaming tar parser and generator. It allows you to create and extract tar archives in a streaming fashion, making it suitable for handling large files or integrating with other streaming APIs.

What are @types/tar-stream's main functionalities?

Creating a tar archive

This feature allows you to create a tar archive by adding entries to it. The example demonstrates how to create a tarball with a single file named 'my-file.txt' containing the text 'Hello, world!'.

const tar = require('tar-stream');
const pack = tar.pack();
const fs = require('fs');

pack.entry({ name: 'my-file.txt' }, 'Hello, world!');
pack.finalize();

pack.pipe(fs.createWriteStream('my-tarball.tar'));

Extracting a tar archive

This feature allows you to extract files from a tar archive. The example demonstrates how to read a tarball and handle each entry as it is extracted.

const tar = require('tar-stream');
const extract = tar.extract();
const fs = require('fs');

extract.on('entry', function(header, stream, next) {
  stream.on('end', next);
  stream.resume();
});

fs.createReadStream('my-tarball.tar').pipe(extract);

Appending files to an existing tar archive

This feature allows you to append new files to an existing tar archive. The example demonstrates how to read an existing tarball, add a new file to it, and write the updated tarball to a new file.

const tar = require('tar-stream');
const fs = require('fs');
const pack = tar.pack();

pack.entry({ name: 'new-file.txt' }, 'New content');
pack.finalize();

const extract = tar.extract();
extract.on('entry', function(header, stream, next) {
  pack.entry(header, function(err, entry) {
    stream.pipe(entry);
    stream.on('end', next);
  });
});

fs.createReadStream('existing-tarball.tar').pipe(extract);
pack.pipe(fs.createWriteStream('updated-tarball.tar'));

Other packages similar to @types/tar-stream

FAQs

Package last updated on 03 Jun 2019

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