Stream Transform examples

This package proposes different API flavours. Every example is available on GitHub.

For additional usages and examples, you may refer to:

Mixing the stream and callback APIs

The output stream example send the data in the form of a string and read the resulted dataset as a stream.

const transform = require('stream-transform')
const assert = require('assert')

const output = []
transform([
  ['1','2','3','4'],
  ['a','b','c','d']
], function(data){
  data.push(data.shift())
  return data
})
.on('readable', function(){
  while(row = this.read()){
    output.push(row)
  }
})
.on('error', function(err){
  console.log(err.message)
})
.on('finish', function(){
  assert.deepEqual(output, [
    [ '2', '3', '4', '1' ],
    [ 'b', 'c', 'd', 'a' ]
  ])
})