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

hyperlog-links

v1.0.0

Published

compute a reverse link index for hyperlog feeds

Downloads

4

Readme

hyperlog-links

compute a reverse link index for hyperlog feeds

example

var links = require('hyperlog-links');
var hyperlog = require('hyperlog');
var concat = require('concat-stream');

var level = require('level');
var ldb = level('/tmp/l.db'), db = level('/tmp/db');
var log = hyperlog(db, { valueEncoding: 'json' });

var ln = links(log, ldb, { live: true });
if (process.argv[2] === 'add') {
    process.stdin.pipe(concat(function (body) {
        var links = process.argv.slice(3);
        log.add(links, body, function (err, node) {
            console.log(node.key);
        });
    }));
}
else if (process.argv[2] === 'get') {
    ln.get(process.argv[3]).on('data', console.log);
}

First we'll populate a hyperlog with some data:

$ echo first | node links.js add
8e6c09d69f670676cba210c9b2b7edaa6d2d7cb1b2efe1fb8391765b6d1e55e5
$ echo second | node links.js add 8e6c09d69f670676cba210c9b2b7edaa6d2d7cb1b2efe1fb8391765b6d1e55e5
8d2d238eb6fb7c63917fd10188d0ba4582ed3882361f5eccbcb44a0c82a8ab00
$ echo third | node links.js add 8d2d238eb6fb7c63917fd10188d0ba4582ed3882361f5eccbcb44a0c82a8ab00
70761ba863de6f58ba14b43688b15b783b8c2e5755f1d5019c108df2f69186a8
$ echo 3rd | node links.js add 8d2d238eb6fb7c63917fd10188d0ba4582ed3882361f5eccbcb44a0c82a8ab00
c9fcaf59c512217e35074ee96eacebdecabf11191ec57281bae19ee1e62a3741
$ echo fourth | node links.js add 70761ba863de6f58ba14b43688b15b783b8c2e5755f1d5019c108df2f69186a8 c9fcaf59c512217e35074ee96eacebdecabf11191ec57281bae19ee1e62a3741
1e3db2a88640304cd9aaa54dfe1648ebd793ad7c75865ebfd98b272657f22c10

We can list the documents that link to any hash:

$ node links.js get 8d2d238eb6fb7c63917fd10188d0ba4582ed3882361f5eccbcb44a0c82a8ab00
{ key: '70761ba863de6f58ba14b43688b15b783b8c2e5755f1d5019c108df2f69186a8' }
{ key: 'c9fcaf59c512217e35074ee96eacebdecabf11191ec57281bae19ee1e62a3741' }
$ node links.js get 70761ba863de6f58ba14b43688b15b783b8c2e5755f1d5019c108df2f69186a8
{ key: '1e3db2a88640304cd9aaa54dfe1648ebd793ad7c75865ebfd98b272657f22c10' }

api

var links = require('hyperlog-links')

var ln = links(log, db, opts)

Create a link instance ln from a hyperlog instance log, a levelup object db, and some options:

  • opts.live - boolean whether to keep the change log open for new updates
  • opts.since - jump to a change sequence directly. Otherwise a change index will be stored in the database automatically.

var r = ln.get(key, cb)

Get all the links to key in a readable object stream r or cb(err, keys).

keys is an array of keys and the object stream returns objects with a key property.

ln.on('error', function (err) {})

Read error events from the underlying link batch machinery here.

install

With npm do:

npm install hyperlog-links

license

MIT