Skip to content

Instantly share code, notes, and snippets.

@dominictarr
Last active April 16, 2024 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominictarr/4366290 to your computer and use it in GitHub Desktop.
Save dominictarr/4366290 to your computer and use it in GitHub Desktop.
function create (path)
var db = require('levelup')(path, {createIfMissing: true})
var Replicator = require('level-replicator')
var replicator = Replicator(db, {
prefix:'replicateable',
merge: function (oldVal, newVal) {
if(!oldVal) return newVal
//handle the differences between old and new,
//the user is expected to implement some version system,
//and store that data in the object...
//vector clocks, or couchdb style hash pointers are good options.
if(illegalUpdate(oldVal, newVal)) throw new Error('invalid')
return merge(oldVal, newVal)
}
})
return replicator
}
var a = create('/tmp/A')
var b = create('/tmp/B')
var as = a.createStream()
as.pipe(b.createStream()).pipe(as)
a.put(key, value)
@ericwetherby
Copy link

Many open-source developers have been posting requests for assistance with project automation and functional testing for uno online.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment