binary-search
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -5,12 +5,16 @@ //Typescript type definition for: | ||
const enum compareResult { | ||
lessThan = -1, | ||
greaterThan = 1, | ||
same = 0 | ||
} | ||
function binarySearch<A>( | ||
haystack: A[], | ||
needle: A, | ||
comparator: (a: A, b: A, index?: number, haystack?: A[]) => compareResult, | ||
comparator: (a: A, b: A, index?: number, haystack?: A[]) => any, | ||
// Notes about comparator return value: | ||
// * when a<b the comparator's returned value should be: | ||
// * negative number or a value such that `+value` is a negative number | ||
// * examples: `-1` or the string `"-1"` | ||
// * when a>b the comparator's returned value should be: | ||
// * positive number or a value such that `+value` is a positive number | ||
// * examples: `1` or the string `"1"` | ||
// * when a===b | ||
// * any value other than the return cases for a<b and a>b | ||
// * examples: undefined, NaN, 'abc' | ||
low?: number, | ||
@@ -17,0 +21,0 @@ high?: number): number; //returns index of found result or number < 0 if not found |
{ | ||
"name": "binary-search", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "tiny binary search function with comparators", | ||
@@ -5,0 +5,0 @@ "license": "CC0-1.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5408
92