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

pump-chain

v1.0.0

Published

A module that glues pump and bubble-stream-error to make things easier when your public API returns a stream.

Downloads

74,954

Readme

pump-chain

A module that glues pump and bubble-stream-error to make life easier when piping streams internally and returning an outer stream.

build status

what problem does it solve?

Consider the situation when you are piping multiple streams internally and returning an outer stream. That stream will be handled by users of your module so you need to make sure that the errors coming from the internal streams propagate to the outer one (which bubble-stream-error takes care of), otherwise they can't be caught and will blow up the process. Also if one of the inner streams closes you want to make sure that the others get closed as well (which pump does).

usage

Simply pass the streams you want to pipe together to pump-chain.

var pump = require('pump-chain');
var crypto = require('crypto');
var fs = require('fs');
var zlib = require('zlib');

function getEncryptedCompressedWordsStream() {
  var gzip = zlib.createGzip();
  var password = new Buffer('car cat tree fireman');
  var aes = crypto.createCipher('aes-256-cbc', password);

  var rs = fs.createReadStream('/usr/share/dict/words');

  // uncomment to simulate an error
  /*
  var i = 0;
  rs.on('data', function() {
    if (++i === 3) {
      this.emit('error', new Error('3 is unlucky!'));
    }
  });
  */

  return pump(rs, aes, gzip);
}

getEncryptedCompressedWordsStream().on('error', function handleError(err) {
  console.error('\n!!! something bad happened while streaming stuff !!!\n');
  throw err;
}).pipe(process.stdout);

tests

npm test

related

mississippi stream utility collection which includes more useful stream modules similar to this one

license

MIT