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-poll

v1.5.1

Published

Create and vote on polls on ssb

Downloads

24

Readme

scuttle-poll

Create and vote on polls on ssb

background details relevant to understanding what this module does

repos:

  • git-ssb: ssb://%uUPqduvyGE2mUBIWdVwMg4jYcKUjxN+TF2wG4a7StM8=.sha256
  • github: [email protected]:ssbc/scuttle-poll.git

Usage

Init

var Sbot = require('ssb-client')
Sbot((err, server) => {
  if (err) {
    return console.log(err)
  }
  var ScuttlePoll = require('scuttle-poll')
  var scuttlePoll = ScuttlePoll(server)
})

where server is a scuttlebot instance (or a remote connection provided by ssb-client)

Note - server can also be an observeable which resolves to a scuttlebot instance (this is more experimental, it will turn your sync functions into obs functions)

This returns an object with methods defined in methods.js that looks like:

{
  poll: {
    async: {
      chooseOne:  
      get:
    },
    sync: {
      isPoll:
      isChooseOnePoll:
    } 
  },
  position: {
    async: {
      chooseOne:
      position:
    
    },
    sync: {
      isPosition:
      chooseOneResults:
    } 
  }
}

Dependencies

Requires a scuttlebutt server with the following plugins installed:

  • ssb-backlinks

API

var ScuttlePoll = require('scuttle-poll')
var scuttlePoll = ScuttlePoll(server)

Methods

scuttle.poll.sync.isPoll(msg) => Boolean

Takes a msg or the contents of a msg

You can also check for subtypes of poll e.g.

isPoll.chooseOne(msg)
// => Boolean

scuttle.poll.async.get(key, cb)

fetches all the messages associated with a particular poll, and returns a delightfully accessible object:

{
  key:        MessageKey,
  value:      MessageValue,

  author:     FeedId,
  title:      String,
  body:       (String|Null),

  positions:  Array,
  myPosition: Object,
  results:    Array,
  resolution: Msessage,
  errors:     Object

  heads:      Array
}

scuttle.poll.async.publishChooseOne(opts, cb)

// NOT BUILT YET

where opts is an object of form:

{
  title: String,    // required
  choices: Array,   // required
  body: String,
}

and cb is a callback of signature (err, newPollMsg)

Install

With npm installed, run

$ npm install scuttle-poll

Schemas

Poll

Poll message content

{
  type:       'poll',          // required
  details: PollDetails     // required
  title:       String,         // required
  closesAt:    Integer         // required
  body:        String,
  channel,
  mentions,
  recps
}

Where PollDetails is an object which has the details needed for each type of poll: Dot, Proposal, Score

Dot vote PollDetails

{
  type: 'dot', // required
  maxStanceScore: 'Integer >= 0', // required
  maxChoiceScore: 'Integer >= 0', //optional
  choices: Array, // required
}

Proposal PollDetails

{
  type: 'proposal', // required
  proposal: String, // required
}

Score PollDetails

{
  type: 'score', // required
  maxChoiceScore: 'Integer >= 0', //required
  choices: Array, // required
}

Position

{
  type:           'position',
  root:            MessageKey,
  details: Object
}

chooseOne details:

{
  choice:

}

Acknowledgments

scuttle-poll was inspired by Loomio! Massive thanks to Rob Guthrie and James Kiesel for spending time giving us a brain dump of their data model.

See Also

License

MIT