stream-value-reader

0.1.0 • Public • Published

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.

Readme

Keywords

Package Sidebar

Install

npm i stream-value-reader

Weekly Downloads

1

Version

0.1.0

License

ISC

Unpacked Size

3.61 kB

Total Files

4

Last publish

Collaborators

  • kodedninja