Binsearch
Perform a 1d bin search where bins are defined by an input edge vector.
Examples
var binsearch = require( 'binsearch' ),
edges, numEdges = 11,
idx;
edges = new Array( numEdges );
for ( var i = 0; i < numEdges; i++ ) {
edges[ i ] = i-0.5;
}
idx = binsearch( edges, 0 );
idx = binsearch( edges, 1 );
idx = binsearch( edges, 5.2345 );
idx = binsearch( edges, 5.5001 );
idx = binsearch( edges, -5 );
idx = binsearch( edges, 100 );
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.