New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

stream-utils

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

stream-utils

Stream utilities with support for stream resets.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

stream-utils

Stream utilities with support for stream resets.

exports

  • ThroughStream([write], [end], [reset]) - creates a new "through" Streams which readable and writable that acts based on the given write, end, and reset handler functions.
  • DuplexStream(writable, readable) - combines a writable stream and a readable stream into a duplexed Stream.
  • Pipeline(stream1, stream2, ...) - creates a new Stream that sends data to all of the given Streams.

Examples

Here's a simple and somewhat contrived example of how you might use the through stream helper to apply a math operation.

var su = require("stream-utils"),
	through = su.ThroughStream;

var inputs = [1, 2, 3],
  outputs = [],
  doubler = through(function(val){  // on data queue doubled value
    this.queue(val * 2);
  })
    .on("data", function(val2){  // on data push into outputs
      outputs.push(val2);
    });

inputs.forEach(doubler.write);

// --> outputs is: [2, 4, 6]

Why?

I needed a set of Stream utilities that would make it easier to build and reuse chains of complex Object stream mutators. Originally I used the event-stream package but I ran into a few issues with my use cases that drove me to roll my own solution based on what I had learned from that code.

License

MIT / Apache2

Keywords

stream

FAQs

Package last updated on 26 Oct 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