0.10.0 • Published 10 years ago

synopsis v0.10.0

Weekly downloads
5
License
ISC
Repository
-
Last release
10 years ago

#synposis

build status

Synopsis is a tool computing the effective deltas between two updates in a sequence of updates.

The approach I'm taking is to take a granularity N, and then precompute skip deltas of size N, N2, N3, etc.

###Simple Counting Example:

// Uber simple Synopsis example that just calculates a running
// total of a sum of integers with granularity of 5
var async = require('async');
var _ = require('lodash');

var s = new Synopsis({
  start: 0,
  granularity: 5,
  patcher: function(prev, patch) {
    return prev + patch;
  },
  differ: function(before, after) {
    return after - before;
  }
});

async.eachSeries(_.range(1, 1001), function(n, cb) {
  s.patch(1, cb);
}, function(err) {
  s.sum(function(err, s) {
    console.log(s); // Outputs 1000
  });

  s.sum(500, function(err, s) {
    console.log(s);  // Outputs 500
  });

  s.delta(0, 10, function(err, d) {
    console.log(d); // Outputs 10
  });

  s.delta(5, 7, function(err, d) {
    console.log(d); // Outputs 2  
  });
});

Configuration

Supports specifying a custom store implementation, defaults to memory store if none is provided.

By doing so, the state of the Synopsis instance can be retained across restarts and none of the delta merging will need to be recomputed.

example:

var s = new Synopsis({
  store: {
    // get the value of the key in the store, or undefined if it isn't
    get: function(key, callback) { ... },
    
    // associate the value to the key in the store, undefined value is effectively a delete operation
    put: function(key, value, callback) { ... },

    // optionally define the following if the store provider has a batch operation for them.
    // getAll: function(keys, callback) { ... batch get hash ... }
    // putAll: function(obj, callback) { ... like setAll, but undefined values are deleted ... }
  }
});
0.10.0

10 years ago

0.9.3

10 years ago

0.9.2

10 years ago

0.9.1

10 years ago

0.9.0

10 years ago

0.8.1

10 years ago

0.8.0

10 years ago

0.7.2

10 years ago

0.7.0

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.1

10 years ago

0.3.4

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago