0.2.0 • Published 8 years ago

stream-to-iter v0.2.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

stream-to-iter

convert a stream (or EventEmitter) into an async iteratable for use with for await of

usage

import streamToIter from 'stream-to-iter'
import fs from 'fs'

const stream = fs.createFileStream(__filename)
for await (const chunk of streamToIter(stream)) {
  console.log('chunk:', chunk)
}

The function has two more optional parameters:

  • event: the event name to listen for. default: data
  • end: the event name for the end of the stream, if this is not correct the AsyncIteratable will never stop. default: end
0.2.0

8 years ago

0.1.0

8 years ago