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

chunk-store-read-stream

v1.0.1

Published

Read an abstract-chunk-store as a stream

Downloads

43

Readme

chunk-store-read-stream Build Status npm

Read an abstract-chunk-store as a stream

abstract chunk store

chunk-store-read-stream allows for a chunk-store to be read as a nodejs Readable stream. Only a portion of the chunk-store can be ready by supplying the start and end options, and the chunk-store can be read while it's not fully populated by supplying the onmiss option.

Usage

var Stream = require('chunk-store-read-stream')
var chunkStore // = some chunk store

stream.on('data', console.log)

Start or end at specified byte indexes of the chunk store

var stream = new Stream(chunkStore, {
  start: 1, // Start reading at byte index 1 of the chunk store
  end: 10   // End after reading the byte at index 10
})

Read a chunk-store that is missing some chunks

var stream = new Stream(chunkStore, { onmiss: onmiss })

function onmiss(err, index, retry) {
  // An error occured while retreiving a chunk at `index`
  // When a chunk is missing, an error is produced.
  
  // ... some time passes and we know the chunk exists now ...
  
  retry()
}

API

var stream = new Stream(chunkStore, [opts])

Instantiates a new nodejs Readable stream for the given chunkStore. The opts argument will be passed into the Readable Stream's options argument. It can also have the following properties:

  • opts.start - The inclusive byte index to start reading at
  • opts.end - The inclusive byte index to stop reading at
  • opts.onmiss - The function to call to handle chunk misses

If opts.end is not given then chunkStore.length - 1 is used instead. One of these properties must be defined.

opts.onmiss = function (err, index, retry) {}

err is the error that was generated from retreiving the chunk at index. The chunk-store interface does not distinguish between errors that occured because the chunk is simply missing or because something worse happend.

Once you know that the chunk does exist, you can call retry(). If an error does occure, this can be passed into retry like retry(err).

License

MIT. Copyright (c) Austin Middleton.