compute-incrmin

1.0.1 • Public • Published

incrmin

NPM version Build Status Coverage Status Dependencies

Provides a method to compute a minimum value incrementally.

Installation

$ npm install compute-incrmin

For use in the browser, use browserify.

Usage

var incrmin = require( 'compute-incrmin' );

incrmin()

Returns an initialized method to compute a minimum value incrementally.

var min = incrmin();

min( [value] )

If provided a value, the method updates and returns the updated min. If not provided a value, the method returns the current min.

min( 2 );
 
console.log( min( 1 ) );
// returns 1
 
min( 3 );
 
console.log( min() );
// returns 1

Note: if values have not yet been provided to min(), min() returns null.

Examples

var incrmin = require( 'compute-incrmin' );
 
// Initialize a method to calculate the min incrementally:
var min = incrmin();
 
// Simulate some data...
for ( var i = 0; i < 1000; i++ ) {
    min( Math.random() * 100 );
}
 
console.log( min() );

To run the example code from the top-level application directory,

$ node ./examples/index.js

Notes

The use case for this module differs from the conventional vector implementation and the stream implementation. Namely, this module decouples the act of updating the min from the act of consuming the min.

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

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

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

License

MIT license.

Copyright

Copyright © 2014-2015. The Compute.io Authors.

Package Sidebar

Install

npm i compute-incrmin

Weekly Downloads

144

Version

1.0.1

License

MIT

Last publish

Collaborators

  • kgryte
  • planeshifter