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

digest-stream

v2.0.0

Published

digest-stream - Simple pass-through stream (RW) which calculates the a crypto digest (sha/md5 hash) of a stream and also the length. Pipe your stream through this to get digest and length. (streams2)

Downloads

23,561

Readme

digest-stream

Simple node.js pass-through stream (RW) which calculates the a crypto digest (sha/md5 hash) of a stream and also the length. Pipe your stream through this to get digest and length. (streams2)

Build Status

Installation

npm install digest-stream

Usage

Provide a the digest algorithm, optional input encoding, digest encoding, and a listener function when you construct the stream. The listener will be called with the resultant digest and length of the stream just prior to end being emitted.

Since this uses the node.js crypto package, refer to http://nodejs.org/api/crypto.html for the specific options available.

  • digestStream(algorithm, [inputEncoding,] digestEncoding, [options], listenerFn) - constructs a new stream instance, the listenerFn will be called prior to the end event being emitted. inputEncoding is optional and defaults to binary if not provided.
  • options - optional streams options
  • listenerFn function signature is fn(digest, dataLength) - digest is the digest for the stream data in the digest encoding format specified when instance was created. dataLength is the length of the data in the stream (provided for convenience). If listenerFn returns an object that is an instance of Error, then the error will be signaled in the stream.
var digestStream = require('digest-stream');
var digest;
var dataLength;
function listenerFn(resultDigest, length) {
  digest = resultDigest;
  dataLength = length;
}
var dstream = digestStream('sha1', 'hex', listenerFn); // create instance
readstream
  .pipe(dstream) // digest and length calculated as it passes through
  .pipe(...)

Goals

  • Easy to use pass-through stream which calculates the digest and length of string or Buffer streamlength of the string
  • Builds on pass-stream to have all the normal pass-through functionality for a spec compliant stream
  • works with node 0.10+ streams2 but is also compatible with 0.8

Why

By making this simple pass-through stream which calculates the digest and length of a stream, it becomes really easy to add this functionality to a streaming workflow, just by piping it through this stream, the digest and length will be available prior to end being fired.

Changes

  • v1.0.0 - listenerFn can return an instance of Error and it will be signaled to the stream

Get involved

If you have input or ideas or would like to get involved, you may:

License