want-have-replication

Replicate anything JSON-serialisable between two peers.


Keywords
p2p, peer to peer, replicate, sync, peer-to-peer, replication
License
ISC
Install
npm install want-have-replication@0.2.1

Documentation

want-have-replication

Replicate anything JSON-serialisable between two peers.

npm version build status ISC-licensed chat on gitter

Installing

npm install want-have-replication

Usage

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'}

Contributing

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.