Module: mathsync/stream

mathsync/stream

Stream handling.
Source:

Methods

<static> newResolver(streamProducer, remote, serialize, deserialize)

Creates a new resolver.
Parameters:
Name Type Description
streamProducer function the no-arg function returning a fresh stream emitting local items each time it is called.
remote Summarizer summarizer producing summaires of the remote side.
serialize Serial~Serialize the item serializer.
deserialize Serial~Deserialize the item deserializer.
Source:
Example

Taking items from a level.js database

var remote = ...
var levelup = require('levelup');
var leveljs = require('level-js');
var db = levelup(name, { db : leveljs });
function serialize(item) {
 // ...
}
function deserialize(buffer) {
 // ...
}
var resolver = require('mathsync/stream').newResolver(function () {
 return db.createReadStream();
}, remote, serialize, deserialize);

<static> newSummarizer(streamProducer, serialize, digester, selector)

Creates a new summarizer.
Parameters:
Name Type Argument Description
streamProducer function the no-arg function returning a fresh stream emitting local items each time it is called.
serialize Serial~Serialize the item serializer.
digester Digest~Digester <optional>
the digester to use, defaults to SHA-1.
selector BucketSelector~Selector <optional>
how to place items in IBF buckets, uses 3 buckets by default.
Source:
Example

Taking items from a level.js database

var levelup = require('levelup');
var leveljs = require('level-js');
var db = levelup(name, { db : leveljs });
function serialize(item) {
 // ...
}
var summarizer = require('mathsync/stream').newSummarizer(function () {
 return db.createReadStream();
}, serialize);