JSPM

binary-search-js-util

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q12903F
  • License ISC

A simple implementation of the binary search algorithm.

Package Exports

  • binary-search-js-util
  • binary-search-js-util/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (binary-search-js-util) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Binary Search Algorithm

A simple npm package for performing binary search on sorted arrays.

Installation

npm install binary-search-js-util

Usage

const binarySearch = require('binary-search-js-util');

const arr = [1, 3, 5, 7, 9];
const target = 7;

const index = binarySearch(arr, target);

if (index === -1) {
  console.log('Target not found');
} else {
  console.log('Target found at index', index);
}