0.0.5 • Published 10 years ago

flow-quantiles v0.0.5

Weekly downloads
3
License
-
Repository
github
Last release
10 years ago

flow-quantiles

Reduce transform stream which computes the quantiles over a stream of numeric data.

Note: in order to calculate the quantiles exactly, all data must be buffered into memory. As a result, this stream acts as a sink. Use caution when applying the transform to large datasets.

Installation

$ npm install flow-quantiles

Examples

var eventStream = require( 'event-stream' ),
	qStream = require( 'flow-quantiles' );

// Create some data...
var data = new Array( 1000 );
for ( var i = 0; i < data.length; i++ ) {
	data[ i ] = Math.round( Math.random() * 100 );
}

// Create a readable stream:
var readStream = eventStream.readArray( data );

// Create a new quantiles stream:
var stream = qStream()
	.quantiles( 10 )
	.stream();

// Pipe the data:
readStream.pipe( stream )
	.pipe( eventStream.stringify() )
	.pipe( process.stdout );

Tests

Unit tests use the Mocha test framework with Chai assertions.

Assuming you have installed Mocha, execute the following command in the top-level application directory to run the tests:

$ mocha

All new feature development should have corresponding unit tests to validate correct functionality.

License

MIT license.


Copyright

Copyright © 2014. Athan Reines.