hypercore-protocol
Advanced tools
Comparing version 6.0.1 to 6.1.0
@@ -76,2 +76,7 @@ var events = require('events') | ||
this.id = -1 | ||
if (this.stream.destroyed) return | ||
if (this.stream.expectedFeeds <= 0 || --this.stream.expectedFeeds) return | ||
this.stream.finalize() | ||
} | ||
@@ -78,0 +83,0 @@ } |
@@ -27,2 +27,3 @@ var stream = require('readable-stream') | ||
this.feeds = [] | ||
this.expectedFeeds = opts.expectedFeeds || 0 | ||
@@ -29,0 +30,0 @@ this._localFeeds = [] |
{ | ||
"name": "hypercore-protocol", | ||
"version": "6.0.1", | ||
"version": "6.1.0", | ||
"description": "Stream that implements the hypercore protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -157,3 +157,3 @@ # hypercore-protocol | ||
``` | ||
message: header + payload | ||
message = header + payload | ||
``` | ||
@@ -160,0 +160,0 @@ |
36
test.js
@@ -349,1 +349,37 @@ var tape = require('tape') | ||
}) | ||
tape('expected feeds', function (t) { | ||
var a = protocol({expectedFeeds: 1}) | ||
a.resume() | ||
a.on('end', function () { | ||
t.pass('should end') | ||
t.end() | ||
}) | ||
var ch = a.feed(KEY) | ||
ch.close() | ||
}) | ||
tape('2 expected feeds', function (t) { | ||
var a = protocol({expectedFeeds: 2}) | ||
var created = 0 | ||
a.resume() | ||
a.on('end', function () { | ||
t.same(created, 2, 'created two feeds') | ||
t.pass('should end') | ||
t.end() | ||
}) | ||
created++ | ||
var ch = a.feed(KEY) | ||
ch.close() | ||
setTimeout(function () { | ||
created++ | ||
var ch = a.feed(OTHER_KEY) | ||
ch.close() | ||
}, 100) | ||
}) |
Sorry, the diff of this file is not supported yet
32913
835