git ssb

2+

Dominic / pull-stream



Commit e7e0d53aa4421ee02973e1349150612fdd489792

Flatten aborts stream of streams and current nested stream.

Jan Bölsche committed on 9/12/2015, 4:52:57 PM
Parent: b070cef3deeb553c603e9bae34a2edc14f718595

Files changed

throughs.jschanged
throughs.jsView
@@ -204,16 +204,25 @@
204204
205205 var flatten = exports.flatten = function (read) {
206206 var _read
207207 return function (abort, cb) {
208- if (abort) return read(abort, cb)
209- if(_read) nextChunk()
210- else nextStream()
208+ if (abort) {
209+ _read ? _read(abort, function(err) {
210+ read(err || abort, cb)
211+ }) : read(abort, cb)
212+ }
213+ else if(_read) nextChunk()
214+ else nextStream()
211215
212216 function nextChunk () {
213217 _read(null, function (err, data) {
214218 if (err === true) nextStream()
215- else if (err) cb(err)
219+ else if (err) {
220+ read(true, function(abortErr) {
221+ // TODO: what do we do with the abortErr?
222+ cb(err)
223+ })
224+ }
216225 else cb(null, data)
217226 })
218227 }
219228 function nextStream () {

Built with git-ssb-web