🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

dat-stream-replicator

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dat-stream-replicator

Streaming replicator for dat-graph

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
3
Created
Source

dat-stream-replicator

Streaming replicator for dat-graph

npm install dat-stream-replicator

build status

Usage

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

var dat = datGraphInstance
var otherDat = anotherDatGraphInstance

var stream = replicator(dat)
var otherStream = replicator(otherDat)

stream.pipe(otherStream).pipe(stream)

API

var stream = replicator(datGraph, [options])

Create a new replication stream for a dat-graph instance. Options include:

{
  // gzip the nodes being sent. both sides have to say `true` for gzip to be enabled
  // defaults to true
  gzip: true,
  // only pull/push or do a two way sync. defaults to sync
  mode: 'sync'
}

var stream = replicator.pull(datGraph, [options])

Shorthand for {mode: 'pull'}

var stream = replicator.push(datGraph, [options])

Shorthand for {mode: 'push'}

Progress monitoring

The stream will emit progress events when pushing / pulling. The events look like this

stream.on('push', function (event) {
  /*
  {
    transferred: nodesPushedSofar,
    length: nodesToBePushedInTotals
  }
  */
})

stream.on('pull', function (event) {
  /*
  {
    transferred: nodesPulledSofar,
    length: nodesToBePulledInTotals
  }
  */
})

You can always access the latest pushed/pulled event as stream.pushed and stream.pulled.

License

MIT

FAQs

Package last updated on 29 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts