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

scuttle-book

v2.0.6

Published

a scuttlebutt helper for all book related messages

Downloads

38

Readme

Scuttle-book

A helper module which covers all your ssb book related needs from fetching book data, creating new book entries, and validating whether a message is of a standard form.

The parts of this modules are :

  • queries / getters
  • publishing helpers

Usage

const Book = require('scuttle-book')
const book = Book(server)   // server is sometimes called sbot

const newBook = {
  title: 'The Dispossessed',
  author: 'Ursula le Guin'
}

book.async.create(newBook, (err, bookMsg) => {
  if (err) // handle error

  book.isBook(bookMsg)
  // => true
})

Constructor API

Book(server, opts)

server is a connection to your scuttlebutt server provided by ssb-client (sometimes called sbot in other docs).

opts (options) an Object with over-ride options for the scuttle-book instance:

Instance API

book.async.create(book, cb)

book - an Object which must at least have title, author. If a book doesn't pass the isBook validator, the callback is called with the errors : cb(errors)

book.async.update(bookId, attributes, cb)

Validates and posts an update to an existing book.

book.async.comment(updateId, latestCommentId, text, cb)

Validates and posts a comment.

latestCommentId is optional, if not provided, it will be calculated.

book.pull.books(opts, hydrate, loadComments)

A stream of all books. If hydrate is passed, all changes to books will also be loaded and the final state of each book returned. Otherwise raw book messages are returned.

FIXME: live instead of updates?

book.pull.comments()

A stream of comments on books

book.pull.updates()

A stream of updates on books. You can filter this yourself to pull out just ratings, or description updates etc).

FIXME: other helpers: shelves, authors, users

book.async.get(key, loadComments, cb)

Gets a reduced state of the 'book as a whole' of the form:

{
  key: MessageId,
  title: String,
  description: String,
  authors: [ String, String, ... ],
  images: [ Image, Image, ... ] // Objects of same form as image property
  series: String, // the name of the series
  seriesNo: String, // the book number

  subjective: { FeedId: {
    review: String,
    rating: String, // e.g. 4
    ratingMax: String, // out of, e.g. 5
    ratingType: String, // text or emoticon
    shelves: [ String, String, .... ],
    genres:  [ String, String, .... ]
    }, ...
  }
}

FIXME:

heads: [ MessageId, .... ], // most recent message(s) in the document/ thread threads: [ MessageId, ... ] // all backlinks in causal order

Schemas

See ssb-book-schema

Development

Run the tests with npm test

Some tests require an sbot to be running and currently use your personal identity to read real books. TODO - build a test harness with an in-memory db.