Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tiny-binary-search

patrickarlt116.9kApache-2.01.0.3

Very small binary search index implimentation.

arcgis, convert, geo, geojson, geometry

readme

tiny-binary-search

npm travis standard

A very small binary search index.

Install

npm install tiny-binary-search

Usage

var index = new BinarySearchIndex([
  { value: 0, id: "A" },
  { value: 1, id: "B" },
  { value: 2, id: "C" },
  { value: 3, id: "D" },
  { value: 4, id: "E" },
  { value: 5, id: "F" },
  { value: 6, id: "G" },
  { value: 7, id: "H" },
  { value: 8, id: "I" },
  { value: 9, id: "J" }
]);

index.query(5); // get the item with a value of 5

index.between(1, 3); // get all items with values between 1 and 3 (inclusive)

index.getIndex(0.5); // get the index of an item with a particular value in the array

index.insert({value: 0.5, id: "AA"}); // insert a single item into the index

index.bulkAdd([
  { value: 1.5, id: "BB" },
  { value: 2.5, id: "CC" },
]); // add an array of items to the index

This module is distributed as a UMD module and can also be used in AMD based systems or as a global under the BinarySearchIndex namespace.

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

changelog

Change log

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

Unreleased

1.0.3

  • cleaned up npm tarball and started exposing pkg.module for downstream ES dependents.

1.0.2

  • Fix bug with the last item not existing in the index when calling between.
  • Add additional tests.

1.0.1

  • Fix Build

1.0.0

  • First Release