New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@kartjim/js-binary-search

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kartjim/js-binary-search

JavaScript binary search implementation.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

binary search npm version Node.js CI

JavaScript binary search implementation.

仿 Python bisect二分函数模块;

install

npm i @kartjim/js-binary-search

import

const { 
    bisect_left, 
    bisect_right 
} = require('@kartjim/js-binary-search');

or use CDN:

<script src="https://cdn.jsdelivr.net/npm/@kartjim/js-binary-search@1.0.2/js-binary-search.min.js"></script>

use

bisect_left([1, 2, 4, 5], 3)     // 2
bisect_left([1, 2, 3, 4, 5], 3)  // 2

bisect_right([1, 2, 4, 5], 3)    // 2
bisect_right([1, 2, 3, 4, 5], 3) // 3

API

export type bisect_left = (
    arr: [], 
    val: number, 
    left: number = 0, 
    right: number = arr.length
) => number;
export type bisect_right = (
    arr: [], 
    val: number, 
    left: number = 0, 
    right: number = arr.length
) => number;

Keywords

algorithm

FAQs

Package last updated on 15 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