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

pup

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pup

Pipe and Unpipe Streams

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
decreased by-15%
Maintainers
1
Weekly downloads
 
Created
Source

Pipe and Unpipe streams

Overview

As of node 0.8.x, there is no way to unpipe streams. This module attemps to fill the gap by providing a pipe(source, destination[, options]) and unpipe(source, destination) functions working in tandem, to do piping and unpiping of streams.

Usage

Install with

npm install pup

Two functions are provided:

  • pipe(source, destination[, options]) : to be used to setup a pipe from source to destination. Same signature as the Stream#pipe method.
  • unpipe(source, destination) : remove the pipe between source and destination. If there are many of those, only the first one is removed. Return true on successful removal, false otherwise.

Example

var fs = require('fs')
var pup = require('pup')

var source = fs.readFileStream('test')
var wrong_destination = fs.readWriteStream('test2')
var destination = fs.readWriteStream('test.bak')

// Pipe to one destination
source.pause()
pup.pipe(source, wrong_destination)

// Then remove it and pipe to another
pup.unpipe(source, wrong_destination)
pup.pipe(source, destination)

// Copy the file test.js, which should only end up in test.bak
source.resume()

Restrictions

This is a bit of a hack that relies on the assumption that there is the same cleanup() listener setup by the Stream#pipe method for the end event on the source and on the destination.

License

MIT

Keywords

FAQs

Package last updated on 22 Sep 2012

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