epidemic-broadcast-trees
Advanced tools
Comparing version 6.2.2 to 6.3.1
19
index.js
@@ -9,2 +9,17 @@ var events = require('./events')(require('./v3')) | ||
function createValidate (isFeed) { | ||
return function (clock) { | ||
for(var k in clock) { | ||
if(!isFeed(k)) { | ||
var _clock = {} | ||
for(var k in clock) { | ||
if(isFeed(k)) _clock[k] = clock[k] | ||
} | ||
return _clock | ||
} | ||
} | ||
return clock | ||
} | ||
} | ||
module.exports = function (opts) { | ||
@@ -37,2 +52,6 @@ var state = events.initialize(opts.id, timestamp()) | ||
}) | ||
if(opts.isFeed) | ||
stream._validate = createValidate(opts.isFeed) | ||
opts.getClock(remote_id, function (err, clock) { | ||
@@ -39,0 +58,0 @@ //check if peer exists in state, because we may |
{ | ||
"name": "epidemic-broadcast-trees", | ||
"description": "", | ||
"version": "6.2.2", | ||
"version": "6.3.1", | ||
"homepage": "https://github.com/dominictarr/epidemic-broadcast-trees", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -95,3 +95,4 @@ # epidemic-broadcast-trees | ||
getAt: function ({id:string, sequence:number}, cb), | ||
append: function (msg, cb) | ||
append: function (msg, cb), | ||
isFeed: function (id), | ||
} | ||
@@ -114,2 +115,5 @@ ``` | ||
`isFeed(id)` is a validation function that returns true if `id` | ||
is a valid feed identifier. If not, it is ignored' | ||
### ebt.onAppend (msg) | ||
@@ -170,1 +174,4 @@ | ||
@@ -34,2 +34,6 @@ var inherits = require('inherits') | ||
EBTStream.prototype._validate = function (clock) { | ||
return clock | ||
} | ||
EBTStream.prototype.write = function (data) { | ||
@@ -42,2 +46,7 @@ if(this.peer.logging) console.error("EBT:recv", JSON.stringify(data, null, 2)) | ||
else { | ||
if(data.clock) | ||
data.clock = this._validate(data.clock) | ||
else | ||
data = this._validate(data) | ||
if(this.version === 2) { | ||
@@ -112,2 +121,1 @@ var _data = data; data = {} | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86395
2051
175