Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@santi100/bisect-lib

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@santi100/bisect-lib - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

5

cjs/index.js
"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++;

7

package.json

@@ -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++;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc