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 🙏

© 2025 – Pkg Stats / Ryan Hefner

kvswarm

v1.0.1

Published

key/value store with horizontal partitioning and p2p content distribution

Downloads

4

Readme

kvswarm

key/value store split across multiple writer nodes (horizontal partitioning) with p2p content distribution and networking

uses random slicing to provide an address space that minimizes moves during resizes and [peermq][] to provide robust delivery of messages with an offline write log

status

  • [x] get/put across multiple nodes
  • [x] hot-swap configuration
  • [ ] move data after capacity adjustment
  • [ ] mirror nodes
  • [ ] redundancy balancing

example

command-line example

In this example, we initialize a swarm with 3 storage nodes (A, B, and C) and authorize nodes X and Y for writing to the swarm.

$ A=$(kvswarm id -d /tmp/a)
$ B=$(kvswarm id -d /tmp/b)
$ C=$(kvswarm id -d /tmp/c)
$ X=$(kvswarm id -d /tmp/x)
$ Y=$(kvswarm id -d /tmp/y)
$ kvswarm init --capacity.$A=5 --capacity.$B=10 --capacity.$C=7 --writer=$X --writer=$Y > config.json
$ kvswarm listen -d /tmp/a -c config.json &
$ kvswarm listen -d /tmp/b -c config.json &
$ kvswarm listen -d /tmp/c -c config.json &

Once all the nodes are setup, you can write documents from nodes X and Y:

$ kvswarm -c config.json -d /tmp/x write --put.greeting=hi
$ kvswarm -c config.json -d /tmp/y write --put.cool=beans
$ kvswarm -c config.json -d /tmp/x connect &
$ kvswarm -c config.json -d /tmp/y connect &

and any node can read from the database:

$ kvswarm -c config.json -d /tmp/x get cool
beans
$ kvswarm -c config.json -d /tmp/y get greeting
hi

api

var kvswarm = require('kvswarm')
var Config = require('kvswarm/config')

var kv = kvswarm(opts)

Create a new kvswarm instance from:

  • opts.network - network interface (use require('peermq/network'))
  • opts.storage - string that represents a base path OR a function that receives a string name argument and returns a random-access adaptor or a string path
  • opts.config - Config instance to set writers and bin slicings
  • opts.bins - object mapping node keys to slicing arrays (see the [random-slicing][] module for how these arrays are formatted)

kv.get(key, opts, cb)

Get the value of a string key as cb(err, value).

kvswarm is in sparse mode by default, so a get() will trigger a download for the relevant key.

opts are passed through to hypercore's get() method.

kv.put(key, value)

Append a PUT message to the write cache for key and value.

The write cache is ephemeral.

kv.del(key)

Append a DEL message to the write cache for key.

The write cache is ephemeral.

kv.flush(opts, cb)

Flush the write cache to the outgoing write logs that correspond to the address space for each key. Less frequent, larger flushes will be faster to process, but the data won't be saved to durable storage until it's written into a write block with flush().

  • opts.ack - when true, wait for an acknowledgement that the write node received this
  • opts.receipt - when true, wait until the write block associated with this flush was written, processed, and the hypercore update has propagated back so you can get() (implies opts.ack)

kv.connect()

Connect to the network swarm.

kv.disconnect()

Disconnect from the network swarm.

kv.listen(cb)

Listen for incoming connections. Write and mirror nodes should call this method.

kv.setWriters(writers, cb)

Set the list of authorized writers as an array of hex string keys.

kv.getWriters(cb)

Get an array of writer nodes by their hex string key as cb(err, writers).

kv.addWriter(key, cb)

Add a writer by its node key as a hex string.

kv.removeWriter(key, cb)

Remove a writer by its node key as a hex string.

kv.setCapacities(capacities)

Set the capacities of write nodes with an object mapping hex string ids to unitless numeric capacities.

kv.setConfig(config, cb)

Set the configuration for the kv to use at runtime.

var config = new Config(opts)

Create a new configuration from:

  • opts.writers - array of node keys authorized to write new messages
  • opts.capacities - object mapping node keys to capacity values (unitless numeric values)

var config = Config.parse(str)

Create a new configuration object from a string str.

var str = config.serialize()

Create a string that can be stored on disk and fed to Config.parse(str) later.

config.update(opts)

Update any of:

  • opts.capacities - new capacities to use. uses existing slices to adjust.
  • opts.writers - new set of writers as an array of hex string keys

config.addWriter(key)

Add a writer by its hex string key

config.removeWriter(key)

Remove a writer by its hex string key

license

license zero parity and apache 2.0 (contributions)