# patchwork-threads

> Library for Patchwork's thread data-structures

Latest version **2.2.1** (published 2016-09-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install patchwork-threads
pnpm add patchwork-threads
yarn add patchwork-threads
bun add patchwork-threads
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2016-09-28 |
| First published | 2015-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Paul Frazee |
| Maintainers | cel, dominictarr, pfraze |
| Keywords | patchwork, data, structure, thread |

## Links

- npm: https://www.npmjs.com/package/patchwork-threads
- Repository: https://github.com/ssbc/patchwork-threads
- Homepage: https://github.com/ssbc/patchwork-threads#readme
- Issues: https://github.com/ssbc/patchwork-threads/issues
- npm.io page: https://npm.io/package/patchwork-threads

## Dependencies (3)

- [multicb](https://npm.io/package/multicb.md) ^1.2.0
- [ssb-msgs](https://npm.io/package/ssb-msgs.md) ^5.2.0
- [pull-stream](https://npm.io/package/pull-stream.md) ^2.28.4

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 2.2.1 (latest) — 2016-09-28
- 2.2.0 — 2016-04-08
- 2.1.1 — 2016-03-31
- 2.1.0 — 2016-03-24
- 2.0.1 — 2016-03-07
- 2.0.0 — 2016-02-17
- 1.2.2 — 2016-02-17
- 1.2.1 — 2016-02-04
- 1.2.0 — 2016-02-02
- 1.1.8 — 2016-01-30
- 1.1.7 — 2016-01-02
- 1.1.6 — 2015-12-20
- 1.1.5 — 2015-12-19
- 1.1.4 — 2015-12-19
- 1.1.3 — 2015-12-11
- … 6 more at https://npm.io/package/patchwork-threads/versions

## README

# patchwork-threads

```js
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)
```

---
_Source: https://npm.io/package/patchwork-threads · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
