- // Finally, wake up any sleeping clients.
- possibly_wakeup_clients();
+var create_json_historic_diff = function(new_json, history_left, new_diff_json, cb) {
+ if (history_left.length == 0) {
+ cb(new_diff_json);
+ return;
+ }
+
+ var histobj = history_left.shift();
+ var diff = delta.JSON_delta.diff(histobj.parsed, new_json.parsed);
+ var diff_text = JSON.stringify(diff);
+ zlib.gzip(diff_text, function(err, buffer) {
+ if (err) throw err;
+ new_diff_json[histobj.last_modified] = {
+ plain: diff,
+ text: diff_text,
+ gzip: buffer,
+ last_modified: new_json.last_modified,
+ };
+ create_json_historic_diff(new_json, history_left, new_diff_json, cb);