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

@santi100/bisect-lib

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@santi100/bisect-lib

[![Build Status](https://github.com/santi100a/bisect-lib/actions/workflows/main.yml/badge.svg)](https://github.com/santi100a/bisect-lib/actions) [![GitHub stars](https://img.shields.io/github/stars/santi100a/bisect-lib.svg)](https://github.com/santi100a/b

  • 0.0.3
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Santi's Bisect Library

Build Status GitHub stars License

  • 🚀 Lightweight and fast
  • 👴 ES3-compliant*
  • 💻 Portable between the browser and Node.js

*Hasn't been tested in an actual ES3 environment. Feel free to open an issue or pull request if you find any non-ES3 thing.

Installation

  • Via NPM: npm install @santi100/bisect-lib
  • Via Yarn: yarn add @santi100/bisect-lib
  • Via PNPM: pnpm install @santi100/bisect-lib

API

  • function bisect<T = unknown>(array: T[], target: T): number; Searches for target through array with a recursive binary-search algorithm (designed for sorted arrays). Returns the index of the first ocurrence of target, or -1 if it's not present.

Tests show it doesn't work correctly for unsorted arrays, so you shouldn't pass them to this function:

bisectLib.bisect([5, 7, 3], 3) // Outputs -1 (not present)

Also, keep in mind this library doesn't do deep equality for now. You can file an issue if you want this feature.

Keywords

FAQs

Package last updated on 25 Feb 2023

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