@okiba/search

1.0.25 • Public • Published

Okiba / search

Search utilities

__

Installation

npm i --save @okiba/search

Or import it directly in the browser

<script type="module" src="https://unpkg.com/@okiba/search/index.js"></script>

Usage

import search from '@okiba/search'

Untranspiled code 🛑

Okiba Core packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:

{
  test: /\.js$/,
  exclude: /node_modules\/(?!(@okiba)\/).*/,
  use: {
    loader: 'babel-loader',
    options: {
      presets: ['@babel/preset-env']
    }
  }
}

binarySearch(data, target, start, end, prop)

Binary searches an array

Arguments

+ data: Array.<Object> or Array.<Number>

data to search

+ target: Number

the value to find

+ start: Number

array index where to start from

+ end: Number

array index where to end to

+ prop: String | optional

property to look into (if data contains objects)

Returns

Number index of the closest element found

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @okiba/search

      Weekly Downloads

      0

      Version

      1.0.25

      License

      MIT

      Unpacked Size

      4.43 kB

      Total Files

      5

      Last publish

      Collaborators

      • fiad
      • ghzmdr
      • lavolpecheprogramma