npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stream-master

v0.0.6

Published

A stream that controls child streams

Downloads

11

Readme

stream-master

stream-master is an API for joining multiple streams together under a single streaming parent. At the current moment, stream-master just combines child streams in arbitrary fashion, but in the future it will emit data events per each child stream in more ordered fashion. It is still possible to isolate individual streams within stream-master because the child function will return the specific stream that has become a child if stream-master.

stream-master also emits a zeroChildren event when all its child streams have emitted end. This is useful if you want all your child streams to finish before doing something else with them.

API

var master = require('stream-master') master is a readable stream in this case, not writable. stream-master exports a single function that takes an options object as an argument. opts.bufSize is the buffer size for the children streams of stream-master (when not passed an argument to the child function). When child streams surpass this buffer limit, they will emit the buffered data.

child function

//bufSize indicates how much data child streams should buffer before emmiting data. pass 0 for data to be emmited without buffering
var master = require('stream-master')({bufSize:1024 * 5}) //returns a readable stream.
  , fs = require('fs')

//each child stream emits data normally, but buffers data to notify parent of incoming data
//parent doesn't emit data until a child stream has buffed max limit or has ended

var child1 = request('http://npmjs.org').pipe(master.child()) //child returns a readable/writable stream
child.pipe(fs.createWriteStream(fileName) //child emits data from the 'request' pipe
//same as:   request('http://saambarati.org/').pipe(master.child()).pipe(fs.createWriteStream(fileName))

var child2 = request('http://nodejs.org').pipe(master.child())

//pass a readable stream as an argument to master.child()
var child3 = master.child( request('http://github.com') ) // child3 === request('http://github.com')
child3.pipe(process.stdout)

master.pipe(fs.createWriteStream(masterFile)) //master emits data of both child1 and child2 and child 3