array-binarysearch
Advanced tools
Comparing version 0.0.3 to 0.0.4
10
index.js
const compare = require('number-compare'); | ||
function binarySearch(arr, val, fn=compare, ths=null, bgn=0, end=arr.length) { | ||
function binarySearch(arr, val, bgn=0, end=arr.length) { | ||
while(bgn<end) { | ||
var m = (bgn+end)>>>1; | ||
if(arr[m]<val) bgn = m+1; | ||
else if(arr[m]>val) end = m; | ||
else return m; | ||
} | ||
return -1; | ||
}; |
{ | ||
"name": "array-binarysearch", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Get index of value in sorted array.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
623
10