streaming-reduce

1.0.1 • Public • Published

running-reduce

Reduce streams to a single value, but with a new value on each new piece of data

usage

var reduce = require('streaming-reduce')

fs.createWriteStream('/path/to/some/file.txt')
  .pipe(reduce.obj(function (memo, chunk) {
    var vowels = chunk.toString().match(/[aeiou]/ig)
    return vowels ? memo + vowels.length : memo
  }, 0))
  .on('data', function (chunk) {
    console.log('Number of vowels seen so far: ' + chunk)
  })

api

transform = reduce([options,] fn, memo)

Creates a transform stream, calling fn(memo, chunk) on each new chunk. memo s updated to be the return value of fn and pushed out. Optional options object is passed to the Tranform stream constructor

transform = reduce.obj([options,] fn, memo)

Same as reduce but sets options.objectMode to true

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    0
  • 1.0.0
    1

Package Sidebar

Install

npm i streaming-reduce

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • allouis