Replicate anything JSON-serialisable between two peers.
npm install want-have-replication
const createPeer = require('want-have-replication')
const A = createPeer('A', item => console.log('A received', item))
A.add('first item')
const B = createPeer('B', item => console.log('B received', item))
B.add(['second', 'item'])
const C = createPeer('C', item => console.log('C received', item))
C.add({third: 'item'})
// A <-> B <-> C replication
const rA = A.replicate()
rA.pipe(B.replicate()).pipe(rA)
const rC = C.replicate()
rC.pipe(B.replicate()).pipe(rC)
A received [second: 'item']
C received [second: 'item']
B received 'first item'
C received 'first item'
B received {third: 'item'}
A received {third: 'item'}
If you have a question or have difficulties using want-have-replication
, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.