# @types/hifo

> TypeScript definitions for hifo

Latest version **1.0.6** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/hifo
pnpm add @types/hifo
yarn add @types/hifo
bun add @types/hifo
```

## 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.0.6 |
| Published | 2023-11-07 |
| First published | 2022-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

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

## Recent versions

- 1.0.6 (latest) — 2023-11-07
- 1.0.2 (ts4.3) — 2023-08-22
- 1.0.1 (ts4.2) — 2022-12-30
- 1.0.0 (ts4.1) — 2022-08-23
- 1.0.5 — 2023-11-06
- 1.0.4 — 2023-10-18
- 1.0.3 — 2023-09-16

## README

# Installation
> `npm install --save @types/hifo`

# Summary
This package contains type definitions for hifo (https://github.com/derhuerst/hifo).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hifo.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hifo/index.d.ts)
````ts
export = hifo;

/**
 * Remembers the highest/lowest values in a data set of any size. Useful if you have a large number of values,
 * but are only interested in the `n` highest (or lowest) ones.
 *
 * @example
 * import hifo = require('hifo');
 *
 * interface Person {
 *     name: string;
 *     age: number;
 * }
 *
 * const people: Person[] = [
 *   { name: 'Alice', age: 23 },
 *   { name: 'Eve', age: 45 },
 *   { name: 'Jane', age: 19 },
 *   { name: 'Bob', age: 30 },
 *   { name: 'John', age: 60 },
 *   // thousands of others
 * ];
 *
 * const oldest = hifo<Person>(hifo.highest('age'), 3);
 * for (const person of people) {
 *   oldest.add(person);
 * }
 *
 * console.log(oldest.data);
 * // =>
 * // [
 * //   { name: 'John', age: 60 },
 * //   { name: 'Eve', age: 45 },
 * //   { name: 'Bob', age: 30 }
 * // ]
 */
declare function hifo<T>(compareFn: hifo.CompareFn<T>, size?: number): hifo.Hifo<T>;

declare namespace hifo {
    function lowest<
        TKeyPrimary extends ObjectKey,
        // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
        TObject extends ObjectWithNumericValue<TKeyPrimary | TKeySecondary>,
        TKeySecondary extends ObjectKey = never,
    >(primary: TKeyPrimary, secondary?: TKeySecondary): CompareFn<TObject>;
    function lowest(): CompareFn<number>;
    function highest<
        TKeyPrimary extends ObjectKey,
        // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
        TObject extends ObjectWithNumericValue<TKeyPrimary | TKeySecondary>,
        TKeySecondary extends ObjectKey = never,
    >(primary: TKeyPrimary, secondary?: TKeySecondary): CompareFn<TObject>;
    function highest(): CompareFn<number>;
    const Hifo: Hifo<unknown>;

    interface Hifo<T> {
        readonly size: number;
        readonly data: readonly T[];
        readonly sort: CompareFn<T>;

        init(sort: CompareFn<T>, size?: number): this;
        add(entry: T): this;
        insert(entry: T): number;
        reset(): this;
    }

    type CompareFn<T> = (left: T, right: T) => number;

    type ObjectKey = string | number | symbol;
    type ObjectWithNumericValue<TKey extends ObjectKey> = {
        [key in TKey]: number;
    };
}

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 03:09:37 GMT
 * Dependencies: none

# Credits
These definitions were written by [BendingBender](https://github.com/BendingBender).

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