Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scuttlebutt

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scuttlebutt

replicate data via scuttlebutt protocol

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
242
decreased by-52.08%
Maintainers
1
Weekly downloads
 
Created
Source

scuttlebutt

<img src=https://secure.travis-ci.org/dominictarr/scuttlebutt.png?branch=master>

A base class that makes implementing datastructures for real-time replication easy.

This seems like a silly name, but I assure you, this is real science. read this: http://www.cs.cornell.edu/home/rvr/papers/flowgossip.pdf

or if you are lazy: http://en.wikipedia.org/wiki/Scuttlebutt (lazyness will get you nowhere, btw)

Usage

subclasses must implement at least histroy and applyUpdate

Scuttlebutt#histroy(sources)

sources is a hash of source_ids: timestamps. histroy must return an array of all known events from all sources That occur after the given timestamps for each source.

The array MUST be in order by timestamp.

{ A: 0,
  B: 2,
  C: 3 }

Scuttlebutt#applyUpdate (update)

Possibly apply a given update to the subclasses model. return true if the update was applied. (see scuttlebutt/model.js for an example of a subclass that does not apply every update)

Examples

var Model = require('scuttlebutt/model')

var a = new Model()
var b = new Model()

a.set(key, value)

b.on('update', console.log)

var s = a.createStream()
s.pipe(b.createStream()).pipe(s)

scuttlebutt subclasses

Any Scuttlebutt subclass is replicated with createStream.

var s = new Scuttlebutt()
var z = new Scuttlebutt()
var zs = z.createStream()

zs.pipe(s.createStream()).pipe(zs)

scuttlebutt/ReliableEventEmitter

A Reliable event emmitter. Multiple instances of an emitter may be connected to each other and will remember events, so that they may be resent after a disconnection or crash.

With this approach it is also possible to persist events to disk, making them durable over crashes.

var Emitter = require('scuttlebutt/events')
var emitter = new Emitter()
emit (event, data)

emit an event. only one argument is permitted.

on (event, listener)

add an event listener.

scuttlebutt/Model

A replicateable Model object.

var Model = require('scuttlebutt/model')
var model = new Model()
get (key)

Get a property

set (key, value)

Set a property

on('update', function (key, value, source))

Emmitted when a property changes. If source !== this.id then it was a remote update.

FAQs

Package last updated on 31 Aug 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc