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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hyperdrive-index

v2.0.0

Published

index changes to a hyperdrive feed

Downloads

4

Readme

hyperdrive-index

index changes to a hyperdrive feed

Use this package to generate indexes to quickly answer questions about files written to hyperdrive. For example, you could create an index that parses exif headers and generates thumbnails for a p2p photo album served over a hyperdrive.

example

This example indexes the number of lines in each file written to hyperdrive.

var level = require('level')
var hyperdrive = require('hyperdrive')
var through = require('through2')
var split = require('split2')
var hdex = require('hyperdrive-index')

var db = level('/tmp/drive.db')
var archive = hyperdrive('/tmp/drive.data')

var dex = hdex({
  archive: archive,
  db: level('/tmp/drive.dex.db'),
  map: function (entry, cb) {
    var ch = archive.checkout(entry.version)
    var stream = ch.createReadStream(entry.name)
    countLines(stream, function (err, lines) {
      if (err) cb(err)
      else db.put(entry.name, lines, cb)
    })
  }
})

var name = process.argv[3]
if (process.argv[2] === 'add') {
  process.stdin.pipe(archive.createWriteStream(name))
} else if (process.argv[2] === 'get') {
  dex.ready(function () {
    db.get(name, function (err, lines) {
      if (err) console.error(err)
      else console.log(lines)
    })
  })
}

function countLines (stream, cb) {
  var n = 0
  stream.pipe(split()).pipe(through(write, end))
  function write (buf, enc, next) { n++; next() }
  function end (next) { cb(null, n) }
}

$ echo -ne 'one\ntwo\nthree' | node dex.js add /hello.txt
$ echo -ne 'wheee' | node dex.js add /what.txt
$ node dex.js get /what.txt
1
$ node dex.js get /hello.txt
3
$ echo -ne 'one\ntwo\nthree\nfour\nfive' | node dex.js add /hello.txt
$ node dex.js get /hello.txt
5

api

var hindex = require('hyperdrive-index')

var dex = hindex(opts)

Create a hyperdrive index dex from:

  • opts.archive - hyperdrive archive opened in live mode
  • opts.db - leveldb instance
  • opts.map(entry, cb) - function to process each new entry object

In your opts.map(entry, cb) function, write your indexes to some persistent storage and call cb(err) when finished. The entry records are metadata objects, like you get from archive.list().

dex.ready(fn)

fn() fires when the indexes are caught up with the latest known value in the hyperdrive feed.

install

npm install hyperdrive-index

license

BSD