3.3.0 • Published 9 years ago

dat-replicator v3.3.0

Weekly downloads
6
License
MIT
Repository
github
Last release
9 years ago

dat-replicator

Replicate a dat instance to another one (in a smart way) using nothing but streams

npm install dat-replicator

Usage

Replicating is a simple as piping a few streams

var replicator = require('dat-replicator')
var r1 = replicator(dat1)
var r2 = replicator(dat2)

var send = r1.send()
var rcvd = r2.receive()

send.pipe(rcvd).pipe(send) // will sync dat1 to dat2

Real world example

First setup a dat instance to receive data. Using tcp this could look like

var replicator = require('dat-replicator')
var net = require('net')

var r = replicator(datReceive) // datReceive is a dat instance

net.createServer(function(socket) {
  socket.pipe(r.receive()).pipe(socket)
}).listen(9090)

Then setup another that instance to send the data. Again using tcp

var r = replication(datSend) // datSend is a dat instance
var socket = net.connect(9090)

socket.pipe(r.send()).pipe(socket)

Thats it! All of the changes that datSend have and that datReceive doesn't will be inserted into datReceive.

Metadata

Per default metadata (the change count etc) is exchanged over the stream as well. If for some reason you already have this do

var send = r1.send({meta:{change:100}})
var rcvd = r2.receive({meta:false})

send.pipe(rcvd).pipe(send)

This will disable the metadata exchange

License

MIT

3.3.0

9 years ago

3.2.2

9 years ago

3.2.1

10 years ago

3.2.0

10 years ago

3.1.0

10 years ago

3.0.5

10 years ago

3.0.4

10 years ago

3.0.3

10 years ago

3.0.2

10 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.0.0

10 years ago

1.0.0

10 years ago

0.7.2

10 years ago

0.7.1

10 years ago

0.7.0

10 years ago

0.6.4

10 years ago

0.6.3

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago