replicate localstorage through scuttlebutt.


replicate localstorage through scuttlebutt.

The same api as scuttlebutt/model but data is saved in the browser using local storage.

var LSSB = require('localstorage-scuttlebutt')
var ls = new LSSB({prefix: prefix, id: id, store: localStorage})
ls.set(key, value)
ls.on('change', function (keyvalue) {

prefix is the name of this instance. If you are using multiple instances, or have other data in localStorage you need to set this. By default, prefix='_lss'.

id should be a unique string that represents the user session. you should save this in localStorage (or a cookie). The same id may be reused across multiple tabs, but not across different browsers or devices.

store defaults to localStorage, but sessionStorage may also be used. (store must have length property and a key() method.

replicate with a normal scuttlebutt/model, across anything that provides a Stream api.

var reconnect = require('reconnect')
var LSSB = require('localstorage-scuttlebutt')
var ls = new LSSB({id: ID, prefix: prefix})
reconnect(function (stream) {
var shoe = require('shoe')
var Model = require('scuttlebutt/model')
var model = new Model(SERVER_ID)
shoe(function (stream) {
}).install(http.createServer(function (reqres) {
  fs.createReadStream(__dirname + '/index.html').pipe(res)

opts represents the identity of the current machine. It should corrispond to the user session in this browser. prefix is the name of this object. You may use multiple localstorage-scuttlebutt instances in different parts of the same application by using different prefixes.

var LSSB = require('localstorage-scuttlebutt')
var opts = {id: id, prefix: prefix}
var model = new LSSB(opts)

connect to a remote instance via a duplex stream.

reconnect(function (stream) {

set a property on an instance.

model.set(key, value)

get a property on an instance.


get all keys on instance as an array.


iterate over all value, key pairs.

model.each(function (value) {

value is first, like in [].forEach