npm.io
0.1.8 • Published 12 years ago

template-stream

Licence
—
Version
0.1.8
Deps
2
Vulns
0
Weekly
0

template-stream

Template Stream

Install

npm install template-stream

Usage

Building your own streams

tStream = new require('template-stream')({ jsonOut: 'auto', filterErrors: false, appendString: '' }) // default config
tStream.bind('onTransform', function(data) {
	// do your processing here
	return data // return data to be pushed down stream, return undefined to filter the data
})

Config

jsonOut json true/false string output down stream. 'auto' = same form as upstream filterErrors false=json parse errors emit the error, true=json parse errors are silently filtered

Statistics

// all
console.log(tStream.stat()) // { processed: 942, filtered: 18, badJson: 2 }

// particular statistic
console.log(tStream.stat('filtered')) // 18

// your own statistics
tStream.bump('myStat')
console.log(tStream.stat()) // { processed: 942, filtered: 18, badJson: 2, myStat: 1 }

License

MIT