stream-value-reader
v0.1.0
Published
Concat a stream and use the value multiple times
Downloads
10
Readme
stream-value-reader
Small wrapper around concat-stream
and pump
for those cases when you need to concat a stream and use its value multiple times, independent of the state of the stream.
Installation
npm i stream-value-reader
Example
var getValue = svr(stream, { encoding: 'string' })
getValue().then(function (value) {
// waits until stream has ended
console.log(value + ' first')
})
stream.push('hello')
stream.push(null)
getValue().then(function (value) {
// reuses the value (approximately)
console.log(value + ' second')
})
API
reader = streamValueReader(stream, opts)
Returns a function that returns a Promise, which will be called with the concatenated stream value.
opts
is forwarded to concat-stream
.