Commit 611dd81d35553e9f46997b8293c9234dedbf14ff
flattern should handle case where input is mixed of collections and non-collections
Dominic Tarr committed on 4/8/2016, 9:56:55 AMParent: 5869c7bbdf17510a0090e86348eee826c268b39a
Files changed
test/flatten.js | changed |
throughs.js | changed |
test/flatten.js | ||
---|---|---|
@@ -120,4 +120,16 @@ | ||
120 | 120 | }) |
121 | 121 | }) |
122 | 122 | }) |
123 | 123 | |
124 | +test('flattern handles stream with normal objects', function (t) { | |
125 | + pull( | |
126 | + pull.values([ | |
127 | + [1,2,3], 4, [5,6,7], 8, 9 ,10 | |
128 | + ]), | |
129 | + pull.flatten(), | |
130 | + pull.collect(function (err, ary) { | |
131 | + t.deepEqual(ary, [1,2,3,4,5,6,7,8,9,10]) | |
132 | + t.end() | |
133 | + }) | |
134 | + ) | |
135 | +}) |
throughs.js | ||
---|---|---|
@@ -238,9 +238,9 @@ | ||
238 | 238 | return cb(end) |
239 | 239 | if(Array.isArray(stream) || stream && 'object' === typeof stream) |
240 | 240 | stream = sources.values(stream) |
241 | 241 | else if('function' != typeof stream) |
242 | - throw new Error('expected stream of streams') | |
242 | + stream = sources.once(stream) | |
243 | 243 | _read = stream |
244 | 244 | nextChunk() |
245 | 245 | }) |
246 | 246 | } |
@@ -252,4 +252,5 @@ | ||
252 | 252 | |
253 | 253 | |
254 | 254 | |
255 | 255 | |
256 | + |
Built with git-ssb-web