Skeleton summarizer/resolver implementation.
- Source:
Methods
-
<static> newResolver(updater, remote, serialize, deserialize)
-
Creates a new resolver.
Parameters:
Name Type Description updater
Summary~SummaryBatchUpdater the updater giving local items. remote
Summarizer summarizer producing summaires of the remote side. serialize
Serial~Serialize the item serializer. deserialize
Serial~Deserialize the item deserializer. - Source:
Example
var remote = ... var items = [{ from: 1, to: 2 }, { from: 2, to: 5}]; function updater(item, done) { items.forEach(item); done(); } function serialize(item) { return new Int32Array([item.from, item.to]).buffer; } function deserialize(buffer) { var arr = new Int32Array(buffer); return { from: arr[0], to: arr[1] }; } var resolver = require('mathsync/skeleton').newResolver(updater, remote, serialize, deserialize);
-
<static> newSummarizer(updater, serialize, digester, selector)
-
Creates a new summarizer.
The summarizer first counts the items as it builds an IBF, and then if the IBF is larger than the total number of items restart building a full content summary. This prevents infinite loops over the level in case of issue, like the same item added twice.
Parameters:
Name Type Argument Description updater
Summary~SummaryBatchUpdater the updater giving local items. 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
var items = [{ from: 1, to: 2 }, { from: 2, to: 5}]; function updater(item, done) { items.forEach(item); done(); } function serialize(item) { return new Int32Array([item.from, item.to]).buffer; } var summarizer = require('mathsync/skeleton').newSummarizer(updater, serialize);