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

patchwork-threads

v2.2.1

Published

Library for Patchwork's thread data-structures

Downloads

18

Readme

patchwork-threads

var threadlib = require('patchwork-threads')

// get the ID of the root message of the thread for any given msg id
threadlib.fetchThreadRootID (ssb, mid, cb)

// get full thread structure
// `opts` used in fetchThreadData
threadlib.getPostThread (ssb, mid, opts, cb)

// get full thread structure, starting possibly from a reply
// `opts` used in fetchThreadData
threadlib.getParentPostThread (ssb, mid, opts, cb)

// get a flattened msg-list of the thread, ready for rendering
threadlib.flattenThread (thread)

// replace each msg in a flattened thread with its latest revision
threadlib.reviseFlatThread(ssb, thread, cb)

// get top-level thread structure (no replies of replies)
// `opts` used in fetchThreadData
threadlib.getPostSummary (ssb, mid, opts, cb)

// get top-level thread structure (no replies of replies), starting possibly from a reply
// `opts` used in fetchThreadData
threadlib.getParentPostSummary (ssb, mid, opts, cb)

// fetch & compute data related to the given thread
// - opts.isRead: attach isread data
// - opts.isBookmarked: attach isBookmarked data
// - opts.votes: compute votes data
threadlib.fetchThreadData (ssb, thread, opts, cb)

// helpers to iterate a thread
threadlib.iterateThread (thread, maxDepth, fn)
threadlib.iterateThreadAsync (thread, maxDepth, fn, cb)

// helpers used in fetchThreadData
threadlib.attachThreadIsread (ssb, thread, maxdepth, cb)
threadlib.attachThreadIsbookmarked (ssb, thread, maxdepth, cb)
threadlib.compileThreadVotes (thread)

// mark all unread msgs in the thread as read
threadlib.markThreadRead (ssb, thread, cb)

// decrypt the msgs in the thread, if not yet decrypted
threadlib.decryptThread (ssb, thread, cb)

// get the last type:post msg in the thread
threadlib.getLastThreadPost (thread)

// get messages that were published as revision to an existing message
threadlib.getRevisions(ssb, thread, callback)

// get the latest revision of an existing message
threadlib.getLatestRevision(ssb, msg, callback)

// count the number of replies in a thread
// - filter(msg): optional additional filter, return bool
threadlib.countReplies(thread, [filter])

// is `a` a reply to `b`?
threadlib.isaReplyTo(a, b)

// does `a` mention `b`?
threadlib.isaMentionTo(a, b)

// does `a` revise `b`?
thread.lib.isaRevisionTo(a, b)