0.0.1 • Published 8 years ago

bigsearch v0.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
8 years ago

Build Status

bigsearch

Fast search for big arrays.
Current functionality: binary search.
To do: Levenshtein.

Usage

var bigsearch = require('bigsearch');

var indexFound = bigsearch.binarySearch(numericArray, target);
var indexFound = bigsearch.binarySearch(stringArray, target, bigsearch.comparators.stringAsc);

The comparators are fully compatible with the Array#sort function. Defining custom comparators:

var indexFound = bigsearch.binarySearch(stringArray, target, function (tgt, elem) {
    return bigsearch.comparators.stringDesc(tgt.stringProp, elem.stringProp);
});

Even though the results are similar to Array#indexOf, this package runs thousands of times (literally) faster, especially when dealing with super large arrays.