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

promisepipe

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promisepipe

Pipe node.js streams safely with Promises

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
548K
increased by16.12%
Maintainers
2
Weekly downloads
 
Created

What is promisepipe?

The 'promisepipe' npm package is designed to facilitate the piping of streams with the added benefit of returning a promise. This can be particularly useful for handling asynchronous stream operations in a more manageable and readable way.

What are promisepipe's main functionalities?

Basic Stream Piping

This feature allows you to pipe a readable stream to a writable stream and returns a promise that resolves when the piping is complete. In this example, a file is read from 'source.txt' and written to 'destination.txt'.

const fs = require('fs');
const promisepipe = require('promisepipe');

async function pipeStreams() {
  const readStream = fs.createReadStream('source.txt');
  const writeStream = fs.createWriteStream('destination.txt');
  await promisepipe(readStream, writeStream);
  console.log('Piping complete');
}

pipeStreams();

Handling Multiple Streams

This feature allows you to pipe multiple streams in sequence. In this example, a file is read from 'source.txt', compressed using gzip, and then written to 'destination.txt.gz'.

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

async function pipeMultipleStreams() {
  const readStream = fs.createReadStream('source.txt');
  const gzipStream = zlib.createGzip();
  const writeStream = fs.createWriteStream('destination.txt.gz');
  await promisepipe(readStream, gzipStream, writeStream);
  console.log('Piping and compression complete');
}

pipeMultipleStreams();

Other packages similar to promisepipe

Keywords

FAQs

Package last updated on 04 Aug 2018

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