@santi100/bisect-lib
Advanced tools
Comparing version 0.0.3 to 0.0.4
"use strict"; | ||
exports.__esModule = true; | ||
exports.bisectMultiple = exports.bisect = void 0; | ||
var cjs_1 = require("@santi100/equal-lib/cjs"); | ||
/** | ||
@@ -39,3 +40,3 @@ * Searches for `target` through `array` with an iterative binary-search algorithm (designed for sorted arrays). | ||
} | ||
else if (array[middle] === target) { | ||
else if ((0, cjs_1.deepEquality)(array[middle], target)) { | ||
return middle; | ||
@@ -77,3 +78,3 @@ } | ||
var i = firstIndex + 1; | ||
while (array[i] === target && i < array.length) { | ||
while ((0, cjs_1.deepEquality)(array[i], target) && i < array.length) { | ||
indices.push(i); | ||
@@ -80,0 +81,0 @@ i++; |
@@ -9,3 +9,3 @@ { | ||
], | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
@@ -26,3 +26,6 @@ "author": "santi100a <santyrojasprieto9@gmail.com>", | ||
}, | ||
"type": "module" | ||
"type": "module", | ||
"dependencies": { | ||
"@santi100/equal-lib": "^1.0.4" | ||
} | ||
} |
@@ -19,3 +19,3 @@ # Santi's Bisect Library | ||
## API | ||
All functions support deep equality. | ||
- `function bisect<T = unknown>(array: T[], target: T): number;` Searches for `target` through `array` with a recursive binary-search algorithm (designed for sorted arrays). Returns the index of the first ocurrence of `target`, or -1 if it's not present. | ||
@@ -27,2 +27,5 @@ | ||
``` | ||
**Also, keep in mind this library doesn't do deep equality for now. You can file an issue if you want this feature.** | ||
- `function bisectMultiple<T extends C, C = T>(array: T[], target: T, opts?: BisectOptions<C>): number;` | ||
Searches for `target` through `array` with an iterative binary-search algorithm | ||
(designed for sorted arrays) and returns an array of indices. See `bisect` for details.} | ||
@@ -0,1 +1,3 @@ | ||
import { deepEquality } from '@santi100/equal-lib/cjs'; | ||
type Comparator<T = unknown> = (a: T, b: T) => number; | ||
@@ -66,3 +68,3 @@ | ||
return middle; | ||
} else if (array[middle] === target) { | ||
} else if (deepEquality(array[middle], target)) { | ||
return middle; | ||
@@ -102,3 +104,3 @@ } else if (comparator) { | ||
let i = firstIndex + 1; | ||
while (array[i] === target && i < array.length) { | ||
while (deepEquality(array[i], target) && i < array.length) { | ||
indices.push(i); | ||
@@ -105,0 +107,0 @@ i++; |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22096
8
331
30
0
1
+ Added@santi100/equal-lib@^1.0.4
+ Added@santi100/equal-lib@1.0.9(transitive)