binarysearch
Advanced tools
Comparing version
@@ -28,2 +28,5 @@ | ||
if(arr.length === 0) return -1; | ||
if(arr.length === 1) return 0; | ||
opts = opts||{}; | ||
@@ -30,0 +33,0 @@ if(!comparitor) comparitor = module.exports._defaultComparitor(); |
{ | ||
"name": "binarysearch", | ||
"description": "pure js binary search for sorted javascript arrays||array like objects. returns any || last || first || closest matched key for value, or slice between 2 values where values need not exist.", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "url": "git://github.com/soldair/node-binarysearch.git" |
@@ -60,1 +60,7 @@ var test = require('tap').test; | ||
test("closest returns -1 on empty array",function(t){ | ||
var key = bs.closest([],99); | ||
t.equals(key,-1,key+' should be -1 because i have no data in the array to be close to'); | ||
t.end(); | ||
}); | ||
13802
1.92%319
2.24%