Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-binarysearch.closest

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-binarysearch.closest - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

12

index.js

@@ -1,3 +0,13 @@

function binarySearch(arr, val, bgn=0, end=arr.length) {
function by(arr, val, fn, ths, bgn, end) {
while(bgn<end) {
var m = (bgn+end)>>>1, c = fn.call(ths, arr[m], val, m, arr);
if(c<0) bgn = m+1;
else if(c>0) end = m;
else return m;
}
return bgn;
};
function binarySearch(arr, val, fn, ths, bgn=0, end=arr.length) {
if(fn!=null) return by(arr, val, fn, ths, bgn, end);
while(bgn<end) {
var m = (bgn+end)>>>1;

@@ -4,0 +14,0 @@ if(arr[m]<val) bgn = m+1;

2

package.json
{
"name": "array-binarysearch.closest",
"version": "0.1.3",
"version": "0.2.0",
"description": "Get index of closest value in sorted array.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc