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

jsonkv

v1.4.1

Published

Single file write-once database that is valid JSON with efficient random access on bigger datasets

Downloads

13

Readme

jsonkv

Single file write-once database that is valid JSON with efficient random access on bigger datasets

npm install jsonkv

Usage

const jsonkv = require('jsonkv')

// First create a database (all data will be stored in ./db.json as valid JSON)
const ws = jsonkv.createWriteStream('db.json')

// Write a ton of data to it
for (var i = 0; i < 10000; i++) {
  ws.write({
    key: i,
    value: `this is a value: ${i}`
  })
}

ws.end(function () {
  // our jsonkv is now fully written and cannot be updated again.
  // to query it make an instance
  const db = jsonkv('db.json')

  db.get(42, function (err, doc) {
    console.log(doc) // prints {key: 42, value: 'this is a value: 42'}
  })
})

API

ws = jsonkv.createWriteStream(filename, [opts])

Create a new database by writing data to the input stream.

All data should be objects and include a sortable primary key. Per default the property key is used. If you want to use another property pass your own sort function as in options.

const ws = jsonkv.createWriteStream('db.json')

ws.write({
  key: 'hello', // per default key is used as the primary key
  world: true
})

The data will be stored temporarily as {filename}.tmp and will then be indexed and stored in filename as a valid JSON file where all the data is stored sorted in a values array with some whitespace padding to make lookups efficient.

The indexing procedure is memory efficient so should be able to handle large datasets as input.

When the stream emits finish the database is safe to use.

db = jsonkv(filename, [opts])

After writing data to a database file you can query by making a database instance.

If you used an optional sort function when writing your data you should pass that here as well.

db.get(key, callback)

Lookup a key. Return the value if found and null otherwise.

rs = db.createReadStream([opts])

Make a readable stream that traverses the database in sorted order.

Options include:

{
  gt: key,  // only keys > than key
  gte: key, // only keys >= than key
  lt: key,  // only keys < than key
  lte: key  // only keys <= than key
}

ite = db.iterate([opts])

Same as above but returns a nanoiterator instance instead of a stream

License

MIT