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

multipipe

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multipipe

pipe streams with centralized error handling

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is multipipe?

The 'multipipe' npm package is a utility for creating a pipeline of streams in Node.js. It allows you to easily combine multiple streams into a single pipeline, handling errors and ensuring proper cleanup of resources.

What are multipipe's main functionalities?

Combining Multiple Streams

This feature allows you to combine multiple streams into a single pipeline. In this example, a file is read, decompressed using gzip, and then extracted using tar-stream. The 'multipipe' function handles the piping and error management.

const multipipe = require('multipipe');
const fs = require('fs');
const zlib = require('zlib');
const tar = require('tar-stream');

const extract = tar.extract();
extract.on('entry', (header, stream, next) => {
  stream.on('end', next);
  stream.resume();
});

const pipeline = multipipe(
  fs.createReadStream('archive.tar.gz'),
  zlib.createGunzip(),
  extract
);

pipeline.on('error', (err) => {
  console.error('Pipeline failed:', err);
});

pipeline.on('finish', () => {
  console.log('Pipeline succeeded');
});

Error Handling

This feature demonstrates how 'multipipe' handles errors in the pipeline. If any stream in the pipeline encounters an error, the 'error' event is emitted, and you can handle it appropriately. In this example, an error will occur because the input file does not exist.

const multipipe = require('multipipe');
const fs = require('fs');
const zlib = require('zlib');

const pipeline = multipipe(
  fs.createReadStream('nonexistentfile.gz'),
  zlib.createGunzip(),
  fs.createWriteStream('output.txt')
);

pipeline.on('error', (err) => {
  console.error('Pipeline error:', err);
});

Other packages similar to multipipe

FAQs

Package last updated on 01 Nov 2016

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