# @types/sorted-array-functions

> TypeScript definitions for sorted-array-functions

Latest version **1.3.3** (published 2023-11-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/sorted-array-functions
pnpm add @types/sorted-array-functions
yarn add @types/sorted-array-functions
bun add @types/sorted-array-functions
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2023-11-21 |
| First published | 2021-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51445 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/sorted-array-functions
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sorted-array-functions
- npm.io page: https://npm.io/package/@types/sorted-array-functions

## Recent versions

- 1.3.3 (latest) — 2023-11-21
- 1.3.0 (ts3.4) — 2021-02-10
- 1.3.2 — 2023-11-07
- 1.3.1 — 2023-10-18

## README

# Installation
> `npm install --save @types/sorted-array-functions`

# Summary
This package contains type definitions for sorted-array-functions (https://github.com/mafintosh/sorted-array-functions).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sorted-array-functions.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sorted-array-functions/index.d.ts)
````ts
export type CompareFn<T = any> = (a: T, b: T) => -1 | 0 | 1;

/**
 * Insert a new value into the list sorted.
 * Optionally you can use a custom compare function that returns, compare(a, b) that returns 1 if a > b, 0 if a === b and -1 if a < b.
 */
export function add<T>(list: T[], value: T, compareFn?: CompareFn<T>): void;

/**
 * Inserts a new value (same result as sorted.add()) optimized for prepend.
 */
export function addFromFront<T>(list: T[], value: T, compareFn?: CompareFn<T>): void;

/**
 * Remove a value.
 * Returns true if the value was in the list.
 */
export function remove<T>(list: T[], value: T, compareFn?: CompareFn<T>): boolean;

/**
 * Check if a value is in the list.
 */
export function has<T>(list: readonly T[], value: T, compareFn?: CompareFn<T>): boolean;

/**
 * Get the index of a value in the list (uses binary search).
 * If the value could not be found, -1 is returned.
 */
export function eq<T>(list: readonly T[], value: T, compareFn?: CompareFn<T>): number;

/**
 * Get the index of the first value that is >=.
 * If the value could not be found, -1 is returned.
 */
export function gte<T>(list: readonly T[], value: T, compareFn?: CompareFn<T>): number;

/**
 * Get the index of the first value that is >.
 * If the value could not be found, -1 is returned.
 */
export function gt<T>(list: readonly T[], value: T, compareFn?: CompareFn<T>): number;

/**
 * Get the index of the first value that is <=.
 * If the value could not be found, -1 is returned.
 */
export function lte<T>(list: readonly T[], value: T, compareFn?: CompareFn<T>): number;

/**
 * Get the index of the first value that is <.
 * If the value could not be found, -1 is returned.
 */
export function lt<T>(list: readonly T[], value: T, compareFn?: CompareFn<T>): number;

export function nearest<T>(list: readonly T[], value: T, compareFn?: CompareFn<T>): number;

````

### Additional Details
 * Last updated: Mon, 20 Nov 2023 23:36:24 GMT
 * Dependencies: none

# Credits
These definitions were written by [Behind The Math](https://github.com/BehindTheMath).

---
_Source: https://npm.io/package/@types/sorted-array-functions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
