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

ssb-index-feeds

v0.10.2

Published

Keep an index feed up-to-date with the content feed

Downloads

126

Readme

ssb-index-feeds

A secret-stack plugin that uses ssb-meta-feeds to create and update index feeds.

Also contains a feed format indexed-v1 under ./format.js.

Installation

Prerequisites:

  • Requires Node.js 10 or higher
  • Requires ssb-db2 version 5.0 or higher
  • Requires ssb-meta-feeds
npm install --save ssb-index-feeds

Add this plugin like this:

 const sbot = SecretStack({ appKey: caps.shs })
     .use(require('ssb-db2'))
     .use(require('ssb-meta-feeds'))
+    .use(require('ssb-index-feeds'))
     // ...

Example usage

There is one primary API this plugin provides: start(). You pass it a ssb-ql-0 query and it will detect whether it needs to create an index feed for that query, or update an existing index feed.

sbot.indexFeeds.start({ author: sbot.id, type: 'vote', private: false }, (err, index) => {
  console.log('The index feed is ' + index.subfeed)
})

From this point onwards, whenever the query gets more results (as the log gets appended), the index feed will be automatically written to.

To stop the index feed from being written to, use stop() with the same query input.

API

sbot.indexFeeds.start(query, cb) (async)

Begins updating an index feed for the given query

query must be an ssb-ql-0 query, either as stringified JSON or as an object.

The callback cb will be called right before the index feed would be written to. If there are no updates to be written on the index feed, this callback will anyway be called. The 1st argument is the possible error, and the 2nd argument is the "subfeed object" containing details on the index feed that matches the query. The subfeed object has the shape { feedpurpose, subfeed, keys, metadata }, the same shape as returned by ssb-meta-feeds APIs.

sbot.indexFeeds.doneOld(query, cb) (async)

Informs you when the index feed for the given query has processed the existing database

query must be an ssb-ql-0 query, either as stringified JSON or as an object.

The callback cb will be called as soon as the writing of the index feed has finished processing all "old" messages on the log. The callback is called with zero arguments.

sbot.indexFeeds.stop(query) (sync)

Cancels the updating of the index feed for the given query, if it had started

query must be an ssb-ql-0 query, either as stringified JSON or as an object.

Does not return anything as a response.

Configuration

Some behaviors of this module can be configured by the user or by application code through the conventional ssb-config object. The possible options are listed below:

{
  indexFeeds: {
    /**
     * If `autostart` is defined as an array, it informs ssb-index-feeds to
     * automatically call `start()` with each of the array items, as soon as
     * this plugin is initialized.
     *
     * The array items are just ssb-ql-0 objects, except without the `author`
     * property, because that one will always be implicitly equal to `sbot.id`.
     */
    autostart: [
      { type: 'vote', private: false },
      { type: 'post', private: false },
      { type: null, private: true },
    ]
  }
}

License

LGPL-3.0