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

level-track

v0.1.0

Published

receive updates from a set of keys and ranges in leveldb

Downloads

8

Readme

level-track

keep track of all the active queries from a request to route live updates

build status

example

In this example we'll subscribe to the range of keys "f" through "p" and the singular key "c". The database is then populated with random keys and values to show that only keys "f" through "p" inclusive and "c" are captured.

var sub = require('level-sublevel');
var db = sub(require('level')('test.db'));
var tracker = require('level-track')(db);
var through = require('through');

var t = tracker();
t.pipe(process.stdout);

t.write('"c"\n');
t.write('["f","p"]\n');

setInterval(function () {
    var l = Math.floor(Math.random() * 2) + 1;
    var key = '';
    for (var i = 0; i < l; i++) {
        key += String.fromCharCode(Math.random() * 26 + 97);
    }
    db.put(key, { n: Math.floor(Math.random() * 100) });
}, 250);

output:

{"type":"put","key":"jr","value":{"n":92}}
{"type":"put","key":"ft","value":{"n":41}}
{"type":"put","key":"g","value":{"n":32}}
{"type":"put","key":"c","value":{"n":55}}
{"type":"put","key":"kh","value":{"n":60}}
{"type":"put","key":"m","value":{"n":43}}
{"type":"put","key":"p","value":{"n":40}}
{"type":"put","key":"nc","value":{"n":64}}
{"type":"put","key":"l","value":{"n":70}}
{"type":"put","key":"fy","value":{"n":41}}
{"type":"put","key":"kp","value":{"n":98}}
{"type":"put","key":"mk","value":{"n":48}}
{"type":"put","key":"h","value":{"n":27}}
^C

protocol

The tracking protocol is newline-delimited json. Each line should match one of these formats:

"key"

Receive updates from a single key.

["startkey","endkey"]

Receive updates from the range "startkey" through "endkey", inclusive.

["startkey","endkey","sincekey"]

Receive updates from the range "startkey" through "endkey", inclusive and populate the result stream with data from the exclusive "sincekey" through "endkey".

This form is useful so that no updates slip past due to delays from rendering the initial content and establishing a live connection.

methods

var tracker = require('level-track')

var t = tracker(opts)

Return a duplex stream that expects input of the form documented in the protocol section and produces output of the form:

{"type":"put","key":"h","value":{"n":27}}

which is the same format that db.hooks and db.batch() use.

When opts.objectMode is true, output is written as objects. Otherwise, output is written as newline-delimited lines of json.

install

With npm do:

npm install level-tracker

license

MIT