Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derhuerst/want-have-replication
Replicate items between two peers.
https://github.com/derhuerst/want-have-replication
p2p peer-to-peer replication sync
Last synced: 17 days ago
JSON representation
Replicate items between two peers.
- Host: GitHub
- URL: https://github.com/derhuerst/want-have-replication
- Owner: derhuerst
- License: isc
- Created: 2017-10-06T05:38:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-05T10:23:50.000Z (over 4 years ago)
- Last Synced: 2024-12-31T11:38:25.696Z (24 days ago)
- Topics: p2p, peer-to-peer, replication, sync
- Language: JavaScript
- Homepage: https://github.com/derhuerst/want-have-replication
- Size: 35.2 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# want-have-replication
**Replicate anything JSON-serialisable between two peers.**
[![npm version](https://img.shields.io/npm/v/want-have-replication.svg)](https://www.npmjs.com/package/want-have-replication)
[![build status](https://img.shields.io/travis/derhuerst/want-have-replication.svg)](https://travis-ci.org/derhuerst/want-have-replication)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/want-have-replication.svg)
[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](https://gitter.im/derhuerst)## Installing
```shell
npm install want-have-replication
```## Usage
```js
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](https://github.com/derhuerst/want-have-replication/issues).