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

bsc

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bsc

Binary search with comparator

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
75K
increased by8.8%
Maintainers
3
Weekly downloads
 
Created
Source

bsc npm

Binary search with comparator.

  • tests not only for the result but for how many steps it takes as well
  • always return -1 if nothing has been found, no "insertion point" negative values
  • no "lower" or "upper bounds"

Install

$ yarn add bsc

Usage

<T>(arr: T[], comparator: (item: T) => number) => number
import binarySearch from 'bsc'

const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

// if comparator return `0` then that item is the result index
binarySearch(arr, (item) => 2 - item) // 2
binarySearch(arr, (item) => 10 - item) // -1

Keywords

FAQs

Package last updated on 14 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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