$ npm install pull-delayed-sink
return a pull-stream sink, that won't start reading until you say.
var delayed = require('pull-delayed-sink')
var feed = [], d
//create a pull stream, and direct to nowhere yet!
pull(pull.values(feed), d = delayed())
//... later, start the sink.
setTimeout(function () {
feed.push(1, 2, 3)
l.start(pull.collect(function (err, ary) {
if(err) throw err
t.deepEqual(ary, [1, 2, 3])
t.end()
}))
})
pull.defer
is a similar function, but it's a source instead of a sink.
create a fake sink stream, and then start it when you have the sink you want.
make a sink delay, and then allow it to start.
MIT
© 2010 - cnpmjs.org x YWFE | Home | YWFE