You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
860 B
38 lines
860 B
var pull = require('pull-stream') |
|
var through = require('through') |
|
var toPull = require('../') |
|
|
|
var stream = require('stream') |
|
|
|
if (stream.Readable) { |
|
require('tape')('issue-3', function (t) { |
|
var util = require('util') |
|
util.inherits(Counter, stream.Readable) |
|
|
|
function Counter() { |
|
stream.Readable.call(this, {objectMode: true, highWaterMark: 1}) |
|
this._max = 5 |
|
this._index = 1 |
|
} |
|
|
|
Counter.prototype._read = function() { |
|
var i = this._index++ |
|
this.push(i) |
|
if (i >= this._max) this.push(null) |
|
}; |
|
|
|
pull( |
|
toPull(new Counter()), |
|
pull.asyncMap(function (value, done) { |
|
process.nextTick(function() { |
|
done(null, value) |
|
}) |
|
}), |
|
pull.collect(function (err, values) { |
|
t.deepEqual(values, [1, 2, 3, 4, 5]) |
|
t.end() |
|
}) |
|
) |
|
|
|
}) |
|
}
|
|
|