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

@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

  • 3.1.3
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
681K
increased by9.49%
Maintainers
1
Weekly downloads
 
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 07 Nov 2023

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